Dangling pointers arise when an object is deleted or de-allocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the de-allocated memory. In short pointer pointing to non-existing memory location is called dangling pointer.
Example:
#include<stdlib.h>{char*ptr =malloc(Constant_Value);.....................free(ptr);/* ptr now becomes a dangling pointer */}
Dangling Pointer in C?
in Programming and Development
Posted
Dangling pointers arise when an object is deleted or de-allocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the de-allocated memory. In short pointer pointing to non-existing memory location is called dangling pointer.
Example: