What is dangling pointer?

Showing Answers 1 - 3 of 3 Answers

manohar

  • Jan 3rd, 2007
 

Dangling pointer is a pointer which is pointing to the destroyed object or which does not have proper address. A pointer should be intialized to zero once it is freed after allocating memory to that pointer. Ex: main() { int *ptr; ptr=(int *)malloc(sizeof(int)); .................. ................. free(ptr); ptr=0; } All pointers should be initialized to zero when declaring them, otherwise we can call it as dangling pointer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions