int *intAddr(){
int i = 16;
return &i;
}
char *charAddr(){
char A = 'a';
return &A;
}
Then I test these two function by
int *intaddr = intAddr();printf("%d\n", *intaddr);
char *charaddr = charAddr();printf(charaddr);
But the result is that only 16 not 'a'. When the funcion intAddr() is over, the variable i
is destroyed. Why the *intaddr
can get 16?