I stumbled upon this function in an answer to this question:
/* Note: I\'ve formatted the code for readability. */
const char * getString() {
const char *x =
In C, string literals have static storage duration. Your code is logically equivalent to:
const char * getString() {
static const char literal[] = "abcstring";
const char *x = literal;
return x;
}
with the exception that in the version with the string literal, the storage for the string could overlap with the storage of other string literals.