How do I update a single char
in a string declared as char*
?
I have tried this:
int main(void)
{
char* s = "hello";
s[0] = 'y';
printf("%s\n", s);
return 0;
}
This compiles without warnings or errors with GCC 4.8.1 (MinGW) using these parameters:
gcc -Wall -Wextra -Werror -o str.exe str.c
But when I run the application, it only prints a blank line?