pointer p, addr of pointer p, value of *p

void pointer(int *p)
{
  int a = 11;
  printf("\nthe p is %p , addr is %p, *p is %d",p , &p, *p);
  *p =11;
  printf("\nthe p is %p , addr is %p, *p is %d",p , &p, *p);
  p = &a;
  printf("\nthe p is %p , addr is %p, *p is %d",p , &p, *p);
}

int main()
{
 int b =22;
 int *p = &b;

 printf("the p is %p , addr is %p, *p is %d",p , &p, *p);
 pointer(p);
 printf("\nthe p is %p , addr is %p, *p is %d\n",p , &p, *p);
}

运行结果:

the p is 00A0FEE4 , addr is 00A0FEDC, *p is 22
the p is 00A0FEE4 , addr is 00A0FEE0, *p is 22
the p is 00A0FEE4 , addr is 00A0FEE0, *p is 11
the p is 00A0FEE8 , addr is 00A0FEE0, *p is 11
the p is 00A0FEE4 , addr is 00A0FEDC, *p is 11

posted on 2015-06-16 09:03  FEMONT  阅读(133)  评论(0)    收藏  举报

导航