StrStartsWith
- Function
- August 22, 2025
Table of Contents
StrStartsWith
StrStartsWith
Description
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:213
:
}
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) {
printf("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