Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4471350
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: C/C++

2011-05-12 19:02:55

指针、数组 转换

*p=NULL

printf("the buf[1]=%d\n",buf[1]);
printf("the buf[1]=%d\n",*(buf++));

printf("the buf[1]=%d\n",p[1]);
printf("the buf[1]=%d\n",*(++p));



  1. #include <stdio.h>

  2. int main()
  3. {
  4.     int buf[4]={234,104,234,9};   0xbfd2afac 4*4=16=0xf
  5.     int *p=NULL;                  0xbfd2afbc
  6.     printf("address buf is %p\n",buf);
  7.     printf("address p is %p\n",&p);

  8.     p=&buf[0];
  9.     printf("address p-buf is %p\n",p);    
  10.     p=buf;
  11.     printf("address p-buf is %p\n",p);

  12.     printf("the buf[1]=%d\n",buf[1]);
  13.     printf("the buf[1]=%d\n",p[1]);
  14.     printf("the buf[1]=%d\n",*(++p));    
  15.     
  16.     return 0;
  17. }

  1. ywx@yuweixian:~/yu/data-struct/c$ ./main
  2. address buf is 0xbfd2afac
  3. address p is 0xbfd2afbc
  4. address p-buf is 0xbfd2afac
  5. address p-buf is 0xbfd2afac
  6. the buf[1]=104
  7. the buf[1]=104
  8. the buf[1]=104






阅读(597) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~