C String literals: Where do they go?
- by Chris Cooper
I have read a lot of posts about "string literals" on SO, most of which have been about best-practices, or where the literal is NOT located in memory.
I am interested in where the string DOES get allocated/stored, etc.
I did find one intriguing answer here, saying:
Defining a string inline actually embeds the data in the program itself and cannot be changed (some compilers allow this by a smart trick, don't bother).
but, it had to do with C++, not to mention that it says not to bother.
I am bothering. =D
So my question is, again, where and how is my string literal kept? Why should I not try to alter it? Does the implementation vary by platform? Does anyone care to elaborate on the "smart trick?"
Thanks for any explanations.