I have this:
char* original = \"html content\";
And want to insert a new
char* mycontent = \"newhtmlinsert\";
Attempting to modify the contents of a string literal results in undefined behavior.
You will need to allocate a target buffer (either as an auto variable or by using malloc
) that's large enough to hold your final string plus a 0 terminator.
Also, you might want to use sprintf
to make life a little easier, such as
sprintf(result, "%s before %s - %s - %s after %s", original,
tag, mycontent, original, tag);