Skip to content
StrStartsWithZstr

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)

Usage examples (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
Last updated on