Consider the following code.
int main(void) {
char * test = "abcdefghijklmnopqrstuvwxyz";
test[5] = 'x';
printf("%s\n", test);
return EXIT_SUCCESS;
}
In my opinion, this should print abcdexghij. However, it just terminates without printing anything.
int main(void) {
char * test = "abcdefghijklmnopqrstuvwxyz";
printf("%s\n", test);
return EXIT_SUCCESS;
}
This however, works just fine, so did I misunderstand the concept of manipulating C strings or something? In case it is important, I'm running Mac OS X 10.6 and it is a 32-bit binary I'm compiling.