Skip to content
StrRemoveRange

StrRemoveRange

StrRemoveRange

Description

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

Parameters

Name Direction Description
str in,out Str to remove char from.
rd out Where removed data will be stored. If not provided then it’s equivalent to deleting the chars in specified range.
start in Index in string to removing chars from.
count in Number of chars from starting index.

Success

return

Failure

Does not return

Usage example (Cross-references)

Usage examples (Cross-references)
                    size_t start = extract_u16(data, offset, size) % VecLen(str);
                    size_t count = extract_u16(data, offset, size) % (VecLen(str) - start + 1);
                    StrRemoveRange(str, (char *)NULL, start, count);
                }
                break;
    // Test StrRemoveRange function
    bool test_str_remove_range(void) {
        WriteFmt("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
Last updated on