sometimes we use this type of code in our C programming.
char *p = "Sam";
Here the address of the line with the constant character "Sam" will be stored in the char p pointer. now hereI want to ask where will Sam be kept?
This is not specified in the standard. Typically, a string literal ( "Sam" ) will be stored in the data section of a read-only page.
"Sam"
As for p itself, it depends on whether it is automatic or static.
p
The string "Sam" is usually stored in global memory in the same area as global constants.
However, if you did this:
char p[] = "Sam";
Then it will be on the stack. (as an array initializer)