Recently I read a thread on stackoverflow that returning a local variable must be avoided whether its a pointer type or a normal variable. I saw an example in my C book and it was returning a local variable, so I thought to try it again
#include <stdio.h>
int func(int a, int b)
{
int d, e, f;
d = a;
e = b;
f = d+e;
return f;
}
int main(void)
{
int c = func(1, 2);
printf("hello\n");//I put this printf in between
printf("c = %d\n", c);//here c should be overwritten
return 0;
}
In that thread it was said, that if I put anything between function call and accessing that variable, I will miss the value.
I am able to access the local variable whatever I do, yet I recall I wrote an example according to that thread and was showing same behaviour as told.
What am I missing?