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

admin2020-11-23  23

问题 有以下程序
#include  <stdio.h>
#include "string.h"
typedef struct{char name[9]; char sex;float score[2];}STU;
void f(STU a)
{
    STU b={"Zhao",’m’,85.0,90.0};  int i;
    strcpy(a.name,b.name);
    a.sex=b.sex;
    for(i=0;i<2;i++) a.score=b.score;
}
程序的运行结果是

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

答案B

解析 本题考查在结构体中函数的实参和形参的传递,调用f(c)后,实参传向形参,进行f()函数功能的实现,但程序中没有返回语句,故形参不能将值传回实参,它们值的传递具有不可逆性,所与printf输出的还是c中实参的值。
转载请注明原文地址:https://kaotiyun.com/show/203p777K
0

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