StrInsertCstr
- Macro
- August 22, 2025
Table of Contents
StrInsertCstr
StrInsertCstr
Description
Insert a string of given length into given Str at given index.
Parameters
Name | Direction | Description |
---|---|---|
str | in,out | Str object to insert into. |
zstr | in | Zero-terminated string to be inserted. |
idx | in | Index to insert the string at. |
len | in | Length of string or number of bytes to insert. |
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Insert.h:52
:
/// FAILURE : Does not return
///
#define StrInsertZstr(str, zstr, idx) StrInsertCstr((str), (zstr), (idx), strlen(zstr))
///
- In
Insert.h:64
:
/// FAILURE : Does not return
///
#define StrInsert(str, str2, idx) StrInsertCstr((str), (str2)->data, (idx), (str2)->length)
///
- In
Str.c:233
:
if (MemCompare(s->data + i, match, match_len) == 0) {
StrDeleteRange(s, i, match_len);
StrInsertCstr(s, replacement, i, replacement_len);
i += replacement_len;
replaced += 1;
- In
Str.Insert.c:58
:
// Test StrInsertCstr function
bool test_str_insert_cstr(void) {
printf("Testing StrInsertCstr\n");
Str s = StrInitFromZstr("Hello");
- In
Str.Insert.c:63
:
// Insert a string in the middle
StrInsertCstr(&s, " World", 2, 6);
// Check that the string was inserted correctly