What happens if I try to define a pointer which points to a string literal in C? -
this question has answer here:
- string literals: go? 8 answers
for example,
char * first = "hello world!";
my questions is,
is string literal stored in memory? (if guess pointer
first
address of inital element of string literal "hello world
")if not, kind of random pointer value stored in
first
?
yes, string literals stored in memory. c , c++ standards string literals have static storage duration, attempt @ modifying them gives undefined behavior, , multiple string literals same contents may or may not share same storage.
Comments
Post a Comment