2 votes 2 votes void main() { char *p="cprogramming"; } I know the string literal "cprogramming" is stored in read only data segment. But where will the pointer p be stored, in stack or read-write data segment ? Programming in C programming-in-c + – sushmita asked Apr 15, 2017 • edited Apr 15, 2017 by dd sushmita 749 views answer comment Share Follow See all 16 Comments See all 16 16 Comments reply Show 13 previous comments Arjun commented Apr 16, 2017 reply Follow Share same, on stack. Because "const char *p" means p is pointing to a constant location (we should not change the contents at the location) but p itself is not a constant. "const * char p" or "char * const p" makes the pointer a constant. Here, the short answer for where "p" is given memory is "implementation defined". For detail: http://stackoverflow.com/questions/1576489/where-are-constant-variables-stored-in-c 0 votes 0 votes akash.dinkar12 commented Apr 16, 2017 reply Follow Share thanx sir!!!!!!!! 0 votes 0 votes sushmita commented Apr 19, 2017 reply Follow Share Thanx a lot sir. Thanku so much. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Different compilers do it in different ways. So, it depends on the compiler that you are using. monanshi answered Apr 19, 2017 monanshi comment Share Follow See all 0 reply Please log in or register to add a comment.