I\'m perplexed as to why the following doesn\'t work:
char * f = \"abcdef\";
strcpy(f, \"abcdef\");
printf(\"%s\",f);
char s[] = \"ffffd\";
strcpy(&s[0],
String literals are considered readonly by most compilers, so the memory where they reside can be marked as readonly, resulting in a runtime error.
To make it work, do the following:
char * f = strdup("abcdef");
strcpy(f, "abcdef");
printf("%s",f);
free(f);
This creates a modifiable copy of the string in the heap memory, which needs to get freed at the end of your program of course.