Here is the code segment I am dealing with. It outputs 500
, but I can not figure out, why this is happening.
#include<stdio.h>
int *f(int x){
int p;
p = x;
printf("p is : %d\n",p);
return &p;
}
int *g(int x){
int y;
y = x;
printf("p is : %d\n",y);
return &y;
}
int main(){
int *x,*y;
x = f(1000);
y = g(250);
*x = *x +250;
printf("%d %d\n",*x,*y);
return 0;
}
What is the reason for the output of 500
?