struct table {
int x, y;
}a[4]={{10, 20}, {30, 40}, {50, 60}, {70, 80}};
struct table *p = a;
printf("%d,", p++->x); /* 以下输出数据之间没有空格分隔 */
printf("%d,", ++p->y);
printf("%d", (a+3)->x);
运行结果是?
printf("%d,", p++->x); ---- p++->x是先执行输出p->x的值,然后p指针后移一位,因此输出的是a数组第0个元素的x值10
printf("%d,", ++p->y); -----++p->y是先将p->y的值加1,然后再输出。由于上一行printf语句将p指针后移,指向a数组第1个元素,因此p->y是40,输出就是41
printf("%d", (a+3)->x); ----a+3就是a的第3个元素,也就是{70,80},因此输出的x值是70
结果是:10,41,70
p++->x 相当于 p->x 输出 a[0].x 对应的值,即为10, 所以输出10; 这时 p 移到 a[1] 位置
++p->y 先计算 p->y, a[1].y 对应的值,即为 40,加1后结果是41,所以输出 41
(a+3)->x 相当于 a[3].x 对应的值,即输出70