StrReplaceCstr
- Function
- August 22, 2025
Table of Contents
StrReplaceCstr
StrReplaceCstr
Description
Replace occurrences of a fixed-length string (Cstr) in string.
Parameters
Name | Direction | Description |
---|---|---|
s | in,out | Str to modify. |
match | in | Match string pointer. |
match_len | in | Length of match string. |
replacement | in | Replacement string pointer. |
replacement_len | in | Length of replacement string. |
count | in | Maximum number of replacements. -1 means replace all occurences. |
Success
Modifies s
in place.
Failure
No replacement if match
not found.
Usage example (Cross-references)
- In
Str.c:247
:
}
void StrReplaceCstr(
Str* s,
const char* match,
- In
Str.Ops.c:144
:
StrDeinit(&s1);
s1 = StrInitFromZstr("Hello World");
StrReplaceCstr(&s1, "World", 5, "Universe", 8, 1);
result = result && (ZstrCompare(s1.data, "Hello Universe") == 0);