选择题
有以下程序:
#include<stdio.h>
struct tt
{ int x; struct tt *y;} s[2]={1,0,2,0};
main()
{ struct tt *p=s;
p->y=s;
printf('%d',++p->x);
}
程序运行后的输出结果是______。
A、
2
B、
0
C、
1
D、
3
【正确答案】
A
【答案解析】
*p=s,可得p指向s[0],p->y指向s[1],现p->y=s,因此p->y指向s[0]。因此p->x=1,++p->x等价于++(p->x),因此打印结果为2。答案为A选项。
提交答案
关闭