若有以下程序 #include #include typedefstructstu{charname[10],gender; intscore; }STU; voidf(char*p) {strcpy(p,"Qian");} main() {STUa={"

admin2020-05-19  32

问题 若有以下程序
#include
#include
typedefstructstu{charname[10],gender;
intscore;
}STU;
voidf(char*p)
{strcpy(p,"Qian");}
main()
{STUa={"Zhao",’m’,290},b;
b=a;
f(b.name);
b.gender=’f’;b.score=350;
printf("%s,%c,%d,",a.name,a.gender,a.score);
printf("%s,%c,%d\n",b.name,b.gender,b.score);
}
则程序的输出结果是

选项 A、Zhao,m,290,Qian,f,350
B、Zhao,m,290, Zhao,m,290
C、Qian,f,350,Qian,f,350
D、Zhao,m,290,Zhao,f,350

答案A

解析 本题考查结构体的相关操作以及传值、传址的区别,该题中调用f函数后,b的name会重新赋值为Qian,选项A正确。
转载请注明原文地址:https://jikaoti.com/ti/FhG0FFFM
0

最新回复(0)