char **s = &"Is this valid?";
Is obtaining the address at which the address of a string literal is stored allowed in C?
I know that the string literal is stored in the .rodata datasegment. However, obtaining the address of that address doesn’t make sense.
It should be noted that gcc compiles this and produces a working executable.
Your example is not valid:
This is valid:
The type of
"Is this valid?"ischar[15]. The type of a pointer to an array 15 ofcharischar (*)[15]. So the type of&"Is this valid?"ischar (*)[15].The type of a string literal is
char[N+1]whereNis the length of the string.