StrStartsWith
- Function
- October 8, 2025
Table of Contents
StrStartsWith
StrStartsWithDescription
Check if string starts with another Str object.
Parameters
| Name | Direction | Description |
|---|---|---|
s | in | Str to check. |
prefix | in | Str to check as prefix. |
Success
Returns true if s starts with prefix.
Failure
Returns false.
Usage example (Cross-references)
- In
Str.c:214:
}
bool StrStartsWith(const Str *s, const Str *prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix->data, prefix->length);
- In
Str.Ops.c:92:
// Test string starts/ends with functions
bool test_str_starts_ends_with(void) {
WriteFmt("Testing StrStartsWith and StrEndsWith variants\n");
Str s = StrInitFromZstr("Hello World");
- In
Str.Ops.c:99:
// Test StrStartsWith
bool result = StrStartsWith(&s, &prefix);
// Test StrEndsWith