#include <stdio.h>
int main(void)
{
int a[][3] = {1, 2, 3, 4, 5, 6};
int (*ptr)[3] = a;
printf("%d %d ", (*ptr)[1], (*ptr)[2]);
++ptr;
printf("%d %d\n", (*ptr)[1], (*ptr)[2]);
return 0;
}
Here, a
has type array[2] of array[3] of
int
, and ptr
initially points to the first array[3] ({1, 2, 3}
). After the increment, it points to the second array[3] ({4, 5, 6}
). Of course,*ptr
denotes the array[3] that
ptr
happens to point to.
int (*ptr)[3]; 声明了一个指针, 指向了一个有3个int元素的数组。
那么打印出来就是
2 3 5 6