关于*和&的数组操作运算对比(三维数组)
作者:互联网
code
#include <stdio.h> int main(void) { int a[2][3][4]={ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95,105, 110,115,120,125}; printf(" a=%08x\n", a); printf(" a+1=%08x\n\n", a+1); printf(" *a=%08x\n", *a); printf(" *a+1=%08x\n\n", *a+1); printf(" **a=%08x\n",**a); printf(" **a+1=%08x\n\n", **a+1); printf(" ***a=%08x\n",***a); printf(" ***a+1=%08x\n\n", ***a+1); printf(" &a=%08x\n", &a); printf(" &a+1=%08x\n\n\n\n\n\n", &a+1); printf(" %08x ",&a[0][0][0]); printf("%08x ",&a[0][0][1]); printf("%08x ",&a[0][0][2]); printf("%08x\n\n",&a[0][0][3]); printf(" %08x ",&a[0][1][0]); printf("%08x ",&a[0][1][1]); printf("%08x ",&a[0][1][2]); printf("%08x\n\n",&a[0][1][3]); printf(" %08x ",&a[0][2][0]); printf("%08x ",&a[0][2][1]); printf("%08x ",&a[0][2][2]); printf("%08x\n\n",&a[0][2][3]); printf(" %08x ",&a[1][0][0]); printf("%08x ",&a[1][0][1]); printf("%08x ",&a[1][0][2]); printf("%08x\n\n",&a[1][0][3]); printf(" %08x ",&a[1][1][0]); printf("%08x ",&a[1][1][1]); printf("%08x ",&a[1][1][2]); printf("%08x\n\n",&a[1][1][3]); printf(" %08x ",&a[1][2][0]); printf("%08x ",&a[1][2][1]); printf("%08x ",&a[1][2][2]); printf("%08x\n\n",&a[1][2][3]); getchar(); return 0; }
运算结果
总结:
1.a+1与a的差值为 3元素*4元素*4字节=48.
2.*a+1与*a的差值为 4元素*4字节=16.
3.**a+1与**a的差值为 1元素*4字节=4
标签:08x,字节,int,元素,三维,差值,数组,printf,运算 来源: https://www.cnblogs.com/kunshanpipixia/p/14608978.html