dangling pointers

Go4Expert Member
10Oct2006,12:23   #1
prem_may10's Avatar
Hi,
Can any one say about the dangling pointer with example

Thanks
yasodhar premchand
Go4Expert Founder
10Oct2006,13:28   #2
shabbir's Avatar
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.