Skip to content

StrContains

StrContains

Description

Check if string contains another Str.

Parameters

Name Direction Description
s in Str object to search in.
key in Str object to search for.

Success

true if a match exists.

Failure

false

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool StrContains(const Str *s, const Str *key) {
        if (!key) {
            LOG_FATAL("Invalid arguments");
    // Test string contains/index functions
    bool test_str_contains_index(void) {
        WriteFmt("Testing StrContains and StrIndexOf variants\n");
    
        Str haystack = StrInitFromZstr("Hello World");
        Str needle   = StrInitFromZstr("World");
    
        bool result = StrContains(&haystack, &needle);
        result      = result && StrContainsZstr(&haystack, "Hello");
        result      = result && StrContainsCstr(&haystack, "lo Wo", 5);
Last updated on