2

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?

Community
  • 1
  • 1
Johnny Pauling
  • 12,701
  • 18
  • 65
  • 108

1 Answers1

5

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 *.

Mike Kwan
  • 24,123
  • 12
  • 63
  • 96