help with string literals

const char * a = "jatt";

in what form ,the string literal above gets stored while compiling?





Last edited on
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.
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'
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
Topic archived. No new replies allowed.