I have this:
char* original = \"html content\";
And want to insert a new
char* mycontent = \"newhtmlinsert\";
Assuming that char* original
is composed by two parts, one starts at 0 while the other (html content after) starts at x
you can use strcat
and memcpy
:
int length = strlen(original)+strlen(newcontent)+1;
char *neworiginal = malloc(sizeof(char)*length);
memset(neworiginal, 0, length);
memcpy(neworiginal,original,x*sizeof(char));
strcat(neworiginal,newcontent);
strcat(neworiginal,original+x);