StrEndsWith
Description
Check whether a Str ends with a suffix.
Three call shapes via OVERLOAD + _Generic on suffix: StrEndsWith(s, suffix) – suffix is Str * or Zstr. StrEndsWith(s, suffix, suffix_len) – suffix is a fixed-length view (Zstr, size).
Parameters
| Name | Direction | Description |
|---|---|---|
s |
in | Str to check. |
suffix |
in | Candidate suffix (Str * / Zstr). |
suffix_len |
in | Length of suffix when using the 3-arg fixed-length form. |
Success
Returns true when s ends with suffix. The string is not modified.
Failure
Returns false. The string is not modified.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.Ops.c:126:
// Test string starts/ends with functions
bool test_str_starts_ends_with(void) {
WriteFmt("Testing StrStartsWith and StrEndsWith variants\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Str.Ops.c:138:
// Test Str-form
result = result && StrEndsWith(&s, &suffix);
// Test Zstr-form (string literal)
- In
Str.Ops.c:145:
// Test Zstr-form (string literal)
result = result && StrEndsWith(&s, "World");
result = result && !StrEndsWith(&s, "Hello");- In
Str.Ops.c:146:
// Test Zstr-form (string literal)
result = result && StrEndsWith(&s, "World");
result = result && !StrEndsWith(&s, "Hello");
// Test Cstr-form (fixed-length view)
- In
Str.Ops.c:153:
// Test Cstr-form (fixed-length view)
result = result && StrEndsWith(&s, "orld", 4);
result = result && !StrEndsWith(&s, "ello", 4);- In
Str.Ops.c:154:
// Test Cstr-form (fixed-length view)
result = result && StrEndsWith(&s, "orld", 4);
result = result && !StrEndsWith(&s, "ello", 4);
StrDeinit(&s);
Last updated on