I have this code:
#include <stdio.h>
#include <math.h>
int *fun();
int main()
{
int *t;
t=fun();
printf("%d\n",*t);
printf("%d\n",*t);
}
int *fun()
{
int r=95;
return(&r);
}
The output shown by this code in codeblocks is
95
-2
I don't get why the second printf()
is printing a garbage value. Can someone explain that, please?