declared char *ptr;
printed the address allocated to ptr (&ptr), garbage address of ptr (ptr ) and the garbage value (*ptr)
Error: Segmentation Fault.
Can you please explain why?
declared char *ptr;
printed the address allocated to ptr (&ptr), garbage address of ptr (ptr ) and the garbage value (*ptr)
Error: Segmentation Fault.
Can you please explain why?
EmbLogic Research & Competency Development Labs
Phone: +91 9818467776, 8527567776, 9650467776
Email: info@emblogic.com
Copyright © EmbLogic Embedded Technologies Pvt. Ltd.
show the code..
sometimes it depends on, how you are printing..
char *ptr;
printf(“Address allocated to ptr is %p\n ptr pointing to garbage address %p\n which holds the garbage value %c\n”,&ptr,ptr,*ptr);
gives segmentation fault (core dumped).
It should at least print the address and garbage value… still facing error.
Well,
On my system it is running very well.. although it should be a segmentation fault in the last print i.e. *ptr… but it is giving some output. But first two are absolutely correct.. no segmentation fault is there..
My system is still giving segmentation fault. I can’t find the reason why the code isn’t giving any output?
maybe the *ptr in ur case is pointing to some address outside its own memory segment.