Local variables popped from stack or is it ?
The value 35 is printed in main. However, I expected a garbage value to be printed since k would be popped off the stack once the function fun() returns.
int * j = fun();
int * fun()
int k = 35;
If I precede the printf statement by some other function call, *j prints out the wrong value implying that the stack contents changed & therefore the wrong value. Does that imply that k remained on stack all this while ?
Can anyone explain exactly how this is working ?