Can you help me to clarify why this instruction fails?:
char * p = "string";
p[0] = 'a';
I have read in http://c-faq.com/decl/strlitinit.html that a string literal...
turns into an unnamed, static array of characters,
and this unnamed array may be stored in read-only memory
and this in 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
This is not completely clear for me:
both concepts refer to the same thing?
if not, which one is correct?
is every constant stored in read-only memory?
Thank you very much in advance.