StrStartsWithZstr
- Function
- August 22, 2025
Table of Contents
StrStartsWithZstr
StrStartsWithZstr
Description
Check if string starts with a null-terminated string (Zstr).
Parameters
Name | Direction | Description |
---|---|---|
s | in | Str to check. |
prefix | in | Null-terminated prefix string. |
Success
Returns true if s
starts with prefix
.
Failure
Returns false.
Usage example (Cross-references)
- In
Str.c:193
:
}
bool StrStartsWithZstr(const Str* s, const char* prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix, ZstrLen(prefix));
- In
Main.c:10
:
// Use the fixed VecForeachPtr macro
VecForeachPtr(&lines, line, {
if (StrStartsWithZstr(line, "[.") && StrEndsWithZstr(line, "]")) {
Str rule_name = StrInit();
StrReadFmt(line->data, "[.{}]", rule_name);
- In
Str.Ops.c:105
:
// Test StrStartsWithZstr
result = result && StrStartsWithZstr(&s, "Hello");
result = result && !StrStartsWithZstr(&s, "World");
- In
Str.Ops.c:106
:
// Test StrStartsWithZstr
result = result && StrStartsWithZstr(&s, "Hello");
result = result && !StrStartsWithZstr(&s, "World");
// Test StrEndsWithZstr