dangling pointers

prem_may10's Avatar, Join Date: Sep 2006
Go4Expert Member
Hi,
Can any one say about the dangling pointer with example

Thanks
yasodhar premchand
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Dangling pointers in programming are pointers which do not point to a valid object.

As an example you allocate a memory using a pointer and deleted it or deallocated using some other pointer and not modifying the value of the first pointer, so now the pointer still points to the memory location of the deallocated memory.

Now if you request the system for reallocation, the previously freed memory may be allocated to another process, and the previous pointer become the dangling pointer.