码迷,mamicode.com
首页 > 其他好文 > 详细

指针与多维数组深度剖析

时间:2014-08-20 12:31:32      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:指针   二维数组   c   

源码

[root@luozhonghua ch10]# cat zippo11.c

/* zippo1.c --  zippo info */
#include <stdio.h>
int main(void)
{


    int b[3]={100,200,300}; int *p;p=b;
    printf("b=%p,*b=%d,p=%p,*p=%d,p+1=%p,*p+1=%d \n",b,*b,p,*p,p+1,*p+1);
    printf("---------------------------\n");


    int zippo[4][2] = { {2,4}, {6,8}, {1,3}, {5, 7} };
    printf("   zippo = %p,    zippo + 1 = %p\n",
               zippo,         zippo + 1);
    printf("zippo[0] = %p, zippo[0] + 1 = %p\n",
            zippo[0],      zippo[0] + 1);
    printf("  *zippo = %p,   *zippo + 1 = %p\n",
              *zippo,        *zippo + 1);
    printf("zippo[0][0] = %d\n", zippo[0][0]);
    printf("  *zippo[0] = %d\n", *zippo[0]);
    printf("    **zippo = %d\n", **zippo);
    printf("      zippo[2][1] = %d\n", zippo[2][1]);
    printf("*(*(zippo+2)) = %d\n", *(*(zippo+2)));
    printf("*(*(zippo+2) + 1) = %d\n", *(*(zippo+2) + 1));
    printf("---------------------------\n");
    printf("*(*(zippo+1)) = %d\n", *(*(zippo+1)));
    printf("*(*(zippo+1) + 1) = %d\n", *(*(zippo+1) + 1));
    printf("*(*(zippo)) = %d\n", *(*(zippo)));
    printf("*(*(zippo)+1) = %d\n", *(*(zippo)+1));
    return 0;

}

结果:

[root@luozhonghua ch10]# ./zippo11
b=0xbfda6dd0,*b=100,p=0xbfda6dd0,*p=100,p+1=0xbfda6dd4,*p+1=101
---------------------------
   zippo = 0xbfda6db0,    zippo + 1 = 0xbfda6db8
zippo[0] = 0xbfda6db0, zippo[0] + 1 = 0xbfda6db4
  *zippo = 0xbfda6db0,   *zippo + 1 = 0xbfda6db4
zippo[0][0] = 2
  *zippo[0] = 2
    **zippo = 2
      zippo[2][1] = 3
*(*(zippo+2)) = 1
*(*(zippo+2) + 1) = 3
---------------------------
*(*(zippo+1)) = 6
*(*(zippo+1) + 1) = 8
*(*(zippo)) = 2
*(*(zippo)+1) = 4


指针与多维数组深度剖析,布布扣,bubuko.com

指针与多维数组深度剖析

标签:指针   二维数组   c   

原文地址:http://blog.csdn.net/luozhonghua2014/article/details/38704141

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!