若有以下程序 #include #include #include structstu{ char*name,gender; intscore; }; main() { structstua={NULL,’m’,290},b; a.name=(char*)

admin2019-05-17  21

问题 若有以下程序
#include
#include
#include
structstu{
char*name,gender;
intscore;
};
main()
{
structstua={NULL,’m’,290},b;
a.name=(char*)malloc(10);
strcpy(a.name,"Zhao");
b=a;b.gender=’f’;b.score=350;
strcpy(b.name,"Qian");
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,Zhao,f,350
B、Zhao,m,290,Qian,f,350
C、Qian,f,350,Qian,f,350
D、Qian,m,290,Qian,f,350

答案D

解析 本题中考查结构体中变量的引用,a结构体中name被修改为Qian,所以本题答案为D。
转载请注明原文地址:https://jikaoti.com/ti/JSf0FFFM
0

随机试题
最新回复(0)