Sunday 3 February 2013


Dangling Pointer:

#include<iostream.h>
#include<conio.h>
int main()
{
char *dp = NULL;
{
char c='A';
dp = &c;
} 
/* c falls out of scope */ 
//cout<<"result="<<c;
/* dp is now a dangling pointer */
cout<<"result="<<dp;
getch();
}

No comments:

Post a Comment