#include<stdio.h>
int main()
{
int var=100;
int *ptr=&var;
fun(&ptr);
printf("%p",ptr);
printf("%d\n",*ptr);
}
int fun(int **var)
{
int j=10;
*var=&j;
printf("%p\n",*var);
printf("%d\n",**var);
}
Output:
0x7fff2c96dba4 10 0x7fff2c96dba4 10
How is value getting retained even after function completing execution? I executed it several times in gcc and in online compiler it gives the same result. please help me in understanding this...Thanks In advance.