StrRemove

Table of Contents

StrRemove

Description

Remove char from string at given index and store in given pointer.

Parameters

NameDirectionDescription
strin,outStr to remove char from.
valoutWhere removed char will be stored. If not provided then it’s equivalent to deleting the char at specified index.
idxinIndex in string to remove char from.

Success

Returns str on success.

Failure

Returns NULL otherwise.

Usage example (Cross-references)

    // Test StrRemove function
    bool test_str_remove(void) {
    printf("Testing StrRemove\n");
    
    Str s = StrInitFromZstr("Hello");
    // Remove a character from the middle
    char c;
    StrRemove(&s, &c, 2);
    
    // Check that the character was removed correctly
    // Remove another character without storing it - avoid passing NULL directly
    char ignored;
    StrRemove(&s, &ignored, 1);
    
    // Check that the character was removed

Share :