Dangling Pointer is a pointer that doesn’t point to a valid memory location. Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory. Following are examples.
int * ptr = ( int *) malloc ( sizeof ( int ));
.......................... free (ptr);
*ptr = 10;
|
int * ptr = NULL
{
int x = 10;
ptr = &x;
}
|