Possible Duplicate:
C String literals: Where do they go?
If I have the following code
char *str = "Tryout" ;
where is the string going to be stored? Stack? If stack, does the pointer point to a stack location then?
Possible Duplicate:
C String literals: Where do they go?
If I have the following code
char *str = "Tryout" ;
where is the string going to be stored? Stack? If stack, does the pointer point to a stack location then?
The string has a static storage class, (likely in read only data) and str
is a local variable with automatic storage. This is why it is better declared as const char *
.