有以下程序: #include<stdio.h> #include<string.h> typedef struct{ char name[9]; char sex; float score[2];}STU; void f(STU*a) { strcpy(

admin2020-01-10  21

问题 有以下程序:
#include<stdio.h>
#include<string.h>
typedef struct{
char name[9];
char sex;
float score[2];}STU;
void f(STU*a)
{
strcpy(a->name,"Zhao");
a->sex=’m’:
a->score[1]=90.0;
}
main()
{
STU c={"Qian",’f’,95,92.0},*d=&c;
f(d);
printf("%s,%c,%2.0f,%2.0f\n",

选项 A、Qian,f,95,92
B、Zhao,f,95,90
C、Zhao,m,95,90
D、Zhao,f,95,92

答案C

解析 f函数调用时,结构体数组名作为实参传给了形参指针,使结构体指针a指向了数组c的首地址。因此,f持有了主函数中数组c的指针,可以对数组c中的元素赋值,故返回主函数之后,数组c中的成员值已被更新。
转载请注明原文地址:https://kaotiyun.com/show/pUCp777K
0

相关试题推荐
随机试题
最新回复(0)