你能帮我澄清一下这条指令失败的原因吗?:
char * p = "string";
p[0] = 'a';
我在http://c-faq.com/decl/strlitinit.html中读到了一个字符串文字......
turns into an unnamed, static array of characters,
and this unnamed array may be stored in read-only memory
,这在http://www.cplusplus.com/doc/tutorial/pointers:
String literals are arrays of the proper array type to contain all
its characters plus the terminating null-character, with each of the
elements being of type const char
这对我来说并不完全清楚:
两个概念都指的是同一个东西?
如果没有,哪一个是正确的?
每个常量都存储在只读存储器中吗?
非常感谢你。