Possible Duplicate:
Modifying C string constants?
Pointer to const char vs char array vs std::string
I know I'm probably beating the dead horse with this question, but I'm a little confused and I haven't managed to find an exact answer on SO or google (that I'm confident is right - there's just too much information on C-strings to sift through). Also, I've tagged it C++ because that's what I'm interested in, even though we're talking about C-style strings specifically.
In this situation:
char const a* = "hello";
char const b[] = "goodbye";
I would have thought that "hello" and "goodbye" were both immutable strings because they come from string-literals that should decay to a char const*.
I've seen that in this particular case though, changing "hello" would be undefined while changing "goodbye" would be fine, assuming you stripped the constness from the b-array.
I assume that the string is mutable in the case of b due to the fact that its stored in a user-defined array.
Are hello and goodbye different in this case? Is goodbye not a string-literal for some reason given this example. Also, if goodbye isn't a string-literal, can I assume it isn't held in global memory, and the only reference to it after compile time is that which is left in the user-array cells?