StrFindStr
- Macro
- August 22, 2025
Table of Contents
StrFindStr
StrFindStr
Description
Find a key in a Str object.
Parameters
Name | Direction | Description |
---|---|---|
str | in | Str object to find str into. |
key | in | Str object to find in str |
Success
char* providing position of found string. Pointer is inside str
Failure
NULL
Usage example (Cross-references)
- In
Str.Ops.c:56
:
// Test string find functions
bool test_str_find(void) {
printf("Testing StrFindStr, StrFindZstr, and StrFindCstr\n");
Str haystack = StrInitFromZstr("Hello World");
- In
Str.Ops.c:64
:
// Test StrFindStr with match at end
const char* found1 = StrFindStr(&haystack, &needle1);
bool result = (found1 != NULL && ZstrCompare(found1, "World") == 0);
- In
Str.Ops.c:68
:
// Test StrFindStr with match at beginning
const char* found2 = StrFindStr(&haystack, &needle2);
result = result && (found2 != NULL && ZstrCompare(found2, "Hello World") == 0);
- In
Str.Ops.c:72
:
// Test StrFindStr with no match
const char* found3 = StrFindStr(&haystack, &needle3);
result = result && (found3 == NULL);