Skip to content

StrSwapCharAt

Description

Swap the characters at two given indices in place. idx1 and idx2 must lie in [0, length). See VecSwapItems for the full SUCCESS/FAILURE contract.

Usage example (Cross-references)

Usage examples (Cross-references)
    // Test StrSwapCharAt function
    bool test_str_swap_char_at(void) {
        WriteFmt("Testing StrSwapCharAt\n");
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        // Swap 'H' and 'o'
        StrSwapCharAt(&s, 0, 4);
    
        // Check that the characters were swapped
    
        // Swap 'e' and 'l'
        StrSwapCharAt(&s, 1, 2);
    
        // Check that the characters were swapped
Last updated on