1 1 vote Determine the output- #include <stdio.h> int main(void) { char *p="gateoverflow"; *(p+5)='z'; printf("%s",p); return 0; } Programming in C programming-in-c output pointers + – Samujjal Das 1.2k views answer comment Share Follow Print See all 6 Comments 6 6 Comments reply bad_engineer commented Feb 6, 2017 reply Follow flag gateozerflow 0 0 replyShare Samujjal Das commented Feb 6, 2017 reply Follow flag Runtime Error 1 1 replyShare Jason_Roy commented Feb 6, 2017 reply Follow flag i think gateozerflow @GateSet, why Runtime error? any reason if you got. 0 0 replyShare bad_engineer commented Feb 6, 2017 reply Follow flag # include <stdio.h> int main() { char s1[7] = "1234", *p; p = s1 + 2; *p = '0'; printf("%s", s1); } this is same as above right?? 0 0 replyShare Samujjal Das commented Feb 6, 2017 reply Follow flag @bad_engineer You are right. I modified your code to match mine. And it is compiling and giving output. I don't know why mine is giving runtime error. 0 0 replyShare Dilip Puri commented Feb 6, 2017 reply Follow flag Segmentation fault 0 0 replyShare Please log in or register to add a comment.
Best answer 5 5 votes The declaration : char *p = "gateoverflow" ; so this suggests that "gateoverflow" is a string constant..And for string constant : Base address can be changed but content cannot be changed.. And reverse happens for array declaration like : char p[15] = "Gateoverflow" .Here base address cannot be changed but content can be changed.. Hence the above code results to runtime error.. Habibkhan answered Feb 6, 2017 • selected Feb 6, 2017 by Samujjal Das Habibkhan comment Share Follow 0 reply Please log in or register to add a comment.