Why do I get a segmentation fault when writing to a “char *s” initialized with a string literal, but not “char s[]”?
See the C FAQ, Question 1.32 Q: What is the difference between these initializations? char a[] = “string literal”; char *p = “string literal”; My program crashes if I try to assign a new value to p[i]. A: A string literal (the formal term for a double-quoted string in C source) can be used in … Read more