StrRemoveRange

Table of Contents

StrRemoveRange

Description

Remove data from string in given range [start, start + count)

Parameters

NameDirectionDescription
strin,outStr to remove char from.
rdoutWhere removed data will be stored. If not provided then it’s equivalent to deleting the chars in specified range.
startinIndex in string to removing chars from.
countinNumber of chars from starting index.

Success

return

Failure

Does not return

Usage example (Cross-references)

    // Test StrRemoveRange function
    bool test_str_remove_range(void) {
    printf("Testing StrRemoveRange\n");
    
    Str s = StrInitFromZstr("Hello World");
    
    // Remove a range of characters
    StrRemoveRange(&s, buffer, 5, 5);
    
    // Check that the characters were removed correctly
    // Remove another range without storing it - use a temporary buffer instead of NULL
    char ignored[2];
    StrRemoveRange(&s, ignored, 4, 2);
    
    // Check that the characters were removed

Share :