I have this code:
void calc(int *ip)
{
int temp = 333;
*ip = temp;
}
int main(void)
{
int a;
calc(&a);
printf("a's value: %d\n", a);
return 0;
}
it prints the right result but I have learned not to trust this! My question
is can I always be sure that the content of ip = temp?
The reason I ask is that int temp is allocated on the stack and after calc
returns temp no longer exists and therefore I thought that printing a in
main would just by coincidence print the right result.