StrSwapCharAt
- Macro
- August 22, 2025
Table of Contents
StrSwapCharAt
StrSwapCharAt
Description
Swap chars at given indices.
Parameters
Name | Direction | Description |
---|---|---|
str | in,out | Str to swap chars in. |
idx1 | in | Index/Position of first char. |
idx1 | in | Index/Position of second char. |
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Str.Memory.c:44
:
// Test StrSwapCharAt function
bool test_str_swap_char_at(void) {
printf("Testing StrSwapCharAt\n");
Str s = StrInitFromZstr("Hello");
- In
Str.Memory.c:49
:
// Swap 'H' and 'o'
StrSwapCharAt(&s, 0, 4);
// Check that the characters were swapped
- In
Str.Memory.c:55
:
// Swap 'e' and 'l'
StrSwapCharAt(&s, 1, 2);
// Check that the characters were swapped