Consider the following code.
int main(void) { char * test = \"abcdefghijklmnopqrstuvwxyz\"; test[5] = \'x\'; printf(\"%s\\n\", test); return EXIT_
Do:
char * bar = strdup(foo); bar[5] = 'x';
strdup makes a modifiable copy.
strdup
And yes, you should really test that strdup didn't return NULL.