Skip to content
StrContainsZstr

StrContainsZstr

StrContainsZstr

Description

Check if string contains a null-terminated string.

Parameters

Name Direction Description
s in Str object to search in.
key in Null-terminated string to search for.

Success

true if a match exists.

Failure

false

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool StrContainsZstr(const Str *s, const char *key) {
        return StrIndexOfZstr(s, key) != SIZE_MAX;
    }
    
        bool result = StrContains(&haystack, &needle);
        result      = result && StrContainsZstr(&haystack, "Hello");
        result      = result && StrContainsCstr(&haystack, "lo Wo", 5);
        result      = result && (StrIndexOf(&haystack, &needle) == 6);
        result      = result && (StrIndexOfZstr(&haystack, "Hello") == 0);
        result      = result && (StrIndexOfCstr(&haystack, "World", 5) == 6);
        result      = result && !StrContainsZstr(&haystack, "missing");
        result      = result && (StrIndexOfZstr(&haystack, "missing") == SIZE_MAX);
        result      = result && StrContainsZstr(&haystack, "");
        result      = result && !StrContainsZstr(&haystack, "missing");
        result      = result && (StrIndexOfZstr(&haystack, "missing") == SIZE_MAX);
        result      = result && StrContainsZstr(&haystack, "");
        result      = result && (StrIndexOfZstr(&haystack, "") == 0);
Last updated on