StrStartsWithZstr

Table of Contents

StrStartsWithZstr

Description

Check if string starts with a null-terminated string (Zstr).

Parameters

NameDirectionDescription
sinStr to check.
prefixinNull-terminated prefix string.

Success

Returns true if s starts with prefix.

Failure

Returns false.

Usage example (Cross-references)

    }
    
    bool StrStartsWithZstr(const Str* s, const char* prefix) {
    ValidateStr(s);
    return starts_with(s->data, s->length, prefix, ZstrLen(prefix));
    // Use the fixed VecForeachPtr macro
    VecForeachPtr(&lines, line, {
    if (StrStartsWithZstr(line, "[.") && StrEndsWithZstr(line, "]")) {
    Str rule_name = StrInit();
    StrReadFmt(line->data, "[.{}]", rule_name);
    
    // Test StrStartsWithZstr
    result = result && StrStartsWithZstr(&s, "Hello");
    result = result && !StrStartsWithZstr(&s, "World");
    // Test StrStartsWithZstr
    result = result && StrStartsWithZstr(&s, "Hello");
    result = result && !StrStartsWithZstr(&s, "World");
    
    // Test StrEndsWithZstr

Share :