cs-self-learning/Cprogramming/2dim_array_pointer.c
2023-05-26 08:45:03 +00:00

16 lines
No EOL
511 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
int main() {
int a[3][4] = {{0,1,2,3}, {4, 5, 6, 7}, {8, 9, 10, 11}};
int(*p)[4] = a;
//一个指向数组的指针p数组的类型为int[4]
printf("%d\n", sizeof(*(p+1))); // 16 that is because 4 * 4 = 16
/**
* *(p+1)单独使用表示第一行数据,放在表达式里就代表第一行数据的首地址
* *(p+1)+1 代表第一行数据的第1个元素的地址
* *(*(p+1)+1) 代表第一行数据的第一个元素
*/
return 0;
}