sometimes we use this type of code in our c programming.
char *p = "Sam";
Here the address of constant character string "Sam" is going to be stored in char pointer p. now here
i want to ask where the Sam is going to be stored ?
sometimes we use this type of code in our c programming.
char *p = "Sam";
Here the address of constant character string "Sam" is going to be stored in char pointer p. now here
i want to ask where the Sam is going to be stored ?
The standard doesn't specify this. Typically the string literal ("Sam") will be stored in the data section, in a read-only page.
As for p itself, it depends on whether it is automatic or static.
data (or maybe bss).data section? On Linux/ELF, string literals get stored with other read-only non-code data in the rodata section, which is in the same segment as text..text and .rodata sections will tipically share a single PT_LOAD program header, see the output of readelf -l).