StrIndexOf
StrIndexOf
Description
Find the index of first occurrence of another Str.
Parameters
| Name | Direction | Description |
|---|---|---|
s |
in | Str object to search in. |
key |
in | Str object to search for. |
Success
Zero-based index of first match.
Failure
SIZE_MAX if no match is found.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.c:194:
}
size StrIndexOf(const Str *s, const Str *key) {
if (!key) {
LOG_FATAL("Invalid arguments");- In
Str.Ops.c:93:
// Test string contains/index functions
bool test_str_contains_index(void) {
WriteFmt("Testing StrContains and StrIndexOf variants\n");
Str haystack = StrInitFromZstr("Hello World");- In
Str.Ops.c:101:
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);
Last updated on