How is this code working if after the control returns to main() variable i is removed from the stack how the value can still be 5 as i doesn't exist in main() and the variable to which the pointer is pointing to does not exist.
#include<stdio.h>
int* sum() {
int i=5;
int*a=&i;
printf("%d\n",a);
return a;
}
int main() {
int* a=sum();
printf("%d\n",a);
printf("%d",*a);
}
output:
2293252
2293252
5