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
  • 11,581
  • 16
  • 61
  • 105

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
  • 23,549
  • 10
  • 59
  • 94