What should happen, when we try to modify a string constant?
问题 #include<stdio.h> #include<string.h> int main() { int i, n; char *x="Alice"; // ....... 1 n = strlen(x); // ....... 2 *x = x[n]; // ....... 3 for(i=0; i<=n; i++) { printf("%s ", x); x++; } printf("\n"); return 0; } String constant cannot be modified. In the above code *x means 'A'. In line 3 we are trying to modify a string constant. Is it correct to write that statement? When I run this code on Linux , I got segmentation fault . But on www.indiabix.com, they have given answer: If you compile