Possible Duplicate:
Why does char* cause undefined behaviour while char[] doesn’t?
Please have a look at the code below
int main (int argc, char* argv[])
{
char* s = "Hello world!";
s[0] = 'X';
return 0;
}
where do the seg fault come from in this code?
Update: On the contrary the code below does not give seg fault, why?
int main (int argc, char* argv[])
{
char s[] = "Hello world!";
s[0] = 'X';
return 0;
}