Saturday, 13 December 2014

Dangling Pointer

Dangling pointer:

If any pointer is pointing the memory address of any variable but after some variable has deleted from that memory location while pointer is still pointing such memory location. Such pointer is known as dangling pointer and this problem is known as dangling pointer problem.
 
for example:
 
#include<stdio.h>
int main()
{
int *p;
{
   int a=10;
   p=&a;
   delete &a;
}
printf("%d",*p);
return 0;
}
 
output:
garbage value

No comments:

Post a Comment