1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

dangling pointers

Discussion in 'C' started by prem_may10, Oct 10, 2006.

  1. prem_may10

    prem_may10 New Member

    Joined:
    Sep 28, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    Can any one say about the dangling pointer with example

    Thanks
    yasodhar premchand
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    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.
     

Share This Page