#include<stdio.h>
char* call();
void hello();
void hello2();
int main()
{
char * p=call();
hello();
hello2();
printf("%c\n",*p);
return 0;
}
void hello()
{
printf("HELLO\n");
}
void hello2()
{
printf("hello2\n");
}
char* call()
{
char a = 's';
char *b = &a;
return b;
}
The above program gives the following output:
HELLO
hello2
s
what I know is when I am calling call() function from main then a stack frame will be allocated in stack and when call() function returns address then memory will be de-allocated but when I am trying to print the value stored in variable 'a' then the output is correct .The confusion I have is that even after de-allocation why the output is correct ?