Skip to content

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)

Usage examples (Cross-references)
    }
    
    bool StrStartsWith(const Str *s, const Str *prefix) {
        ValidateStr(s);
        return starts_with(s->data, s->length, prefix->data, prefix->length);
    // 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");
    
        // Test StrStartsWith
        bool result = StrStartsWith(&s, &prefix);
    
        // Test StrEndsWith
Last updated on