StrStartsWithCstr

Table of Contents

StrStartsWithCstr

Description

Check if string starts with a fixed-length C-style string (Cstr).

Parameters

NameDirectionDescription
sinStr to check.
prefixinPointer to prefix character array.
prefix_leninLength of prefix.

Success

Returns true if s starts with prefix.

Failure

Returns false.

Usage example (Cross-references)

    }
    
    bool StrStartsWithCstr(const Str* s, const char* prefix, size prefix_len) {
    ValidateStr(s);
    return starts_with(s->data, s->length, prefix, prefix_len);
    
    // Test StrStartsWithCstr
    result = result && StrStartsWithCstr(&s, "Hell", 4);
    result = result && !StrStartsWithCstr(&s, "Worl", 4);
    // Test StrStartsWithCstr
    result = result && StrStartsWithCstr(&s, "Hell", 4);
    result = result && !StrStartsWithCstr(&s, "Worl", 4);
    
    // Test StrEndsWithCstr

Share :