I have this snippet :
func(int **t)
{
int q = 40;
*t = &q;
}
int main()
{
int a = 20;
int *p = &a;
func(&p);
printf("%d\n", *p);
}
This program outputs 40 , since pointer p is pointing to address of q instead of a, after *t = &q.
But once we returned from func(int **t), q is no longer exist but still *p gives 40, how ?