Breaking News
Loading...

Dangling pointer in c programming

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>


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

 
Toggle Footer