2011年3月23日 星期三

Old memories never disappear, they just change.

int *bar(int t)
{
  int i = t;
  int *temp = &i;
  printf("temp is %d, (*temp) is %d\n", temp, *temp);
  return temp;
}

void foo(int a, int b, int c)
{
  int i = 40;
}

int main()
{
  int *a;
  a = bar(10);
  printf("a is %d, (*a) is %d \n", a, *a);
  foo(10, 20, 30);
  printf("a is %d, (*a) is %d \n", a, *a);
}

The output.

temp is 2686740, (*temp) is 10
a is 2686740, (*a) is 10
a is 2686740, (*a) is 40

沒有留言:

張貼留言