In this pointer is pointing the memory address of 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.
Example :
#include<stdio.h>
Example :
#include<stdio.h>
int * fun()
{
static int a=99;
++a;
return &a;
}
void main()
{
int *p;
p=fun();
fflush(stdin);
printf("%d",*p);
}
Output: 100
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.