Skip to content

StrInsert

StrInsert

Description

Insert contents of str2 into str at given index.

Parameters

Name Direction Description
str in,out Str object to insert into.
str2 in Str object to be inserted.
idx in Index to insert at.

Success

return

Failure

Does not return

Usage example (Cross-references)

Usage examples (Cross-references)
                    size_t idx  = extract_u16(data, offset, size) % (VecLen(str) + 1);
                    Str    temp = generate_str_from_input(data, offset, size, 20);
                    StrInsert(str, &temp, idx);
                    StrDeinit(&temp);
                }
    // Test StrInsert function
    bool test_str_insert(void) {
        WriteFmt("Testing StrInsert\n");
    
        Str s1 = StrInitFromZstr("Hello");
    
        // Insert s2 into s1 in the middle
        StrInsert(&s1, &s2, 2);
    
        // Check that the string was inserted correctly
Last updated on