Apr 22, 2014 at 6:08pm UTC
const char * a = "jatt";
in what form ,the string literal above gets stored while compiling?
Last edited on Apr 22, 2014 at 6:20pm UTC
Apr 22, 2014 at 6:20pm UTC
You're declaring a
to be a pointer that points to a char type variable that cannot be changed through the pointer. A pointer itself holds a memory address. "jatt" isn't going to be a valid assignment here.
Apr 22, 2014 at 6:24pm UTC
It's a c-string wildblue.
It gets stored like
address a = 'j'
address a+1 = 'a'
address a+2 = 't'
address a+3 = 't'
address a+4 = '\0'
Apr 22, 2014 at 6:47pm UTC
Thanks for the correction giblit. I tried to compile on ideone and it hung.
Edit: So that's essentially creating a character array on the stack with no name that can only be accessed through the pointer?
Last edited on Apr 22, 2014 at 7:13pm UTC