C Collections

cstring · Section 3

cstring_insert

cstring_insert - insert a C string at a given position

C Collections (libccollections, -lccollections)

#include <ccollections/cstring.h>
 
ccol_retval cstring_insert(cstr s, size_t pos, const char *str);

This function inserts the null-terminated C string str at position pos of
s, and the characters at positions >= pos move right to make room. A pos
of 0 does the same as cstring_prepend(), and a pos equal to the length
does the same as cstring_append().

s     String to change
pos   Insertion position (0 ... length, inclusive)
str   C string to insert (must not be NULL)

ccol_success              - The insert succeeded
ccol_invalid_args         - str is NULL, or pos > length
ccol_container_full       - The result would overflow a size_t
ccol_not_enough_memory    - The reallocation failed

Asserts if s is NULL

cstring_append(3), cstring_prepend(3)