有以下程序 #include <stdio.h> #include <string.h> struct A { int a; char b[10]; double c; }; struct A f(struct A t);

admin2021-02-25  15

问题 有以下程序
#include <stdio.h>
#include <string.h>
struct  A
{  
    int a;
    char b[10];
    double c;
};
struct A f(struct A t);
main()
{
    struct A a={1001,"ZhangDa",1098.0};
    a=f(a);
    printf("%d,%s,%6.1f\n",a.a,a.b,a.c);
}
struct A  f(struct A  t)
{
    t.a=1002;
    strcpy(t.b,"ChangRong");
    t.c=1202.0;
    return t;
}
程序运行后的输出结果是

选项 A、1002,ZhangDa,1202.0
B、1002,ChangRong,1202.0
C、1001,ChangRong,1098.0
D、1001,ZhangDa,1098.0

答案B

解析 本题考查结构体变量的引用以及作为函数参数,题目虽然看似复杂,其实比较容易,f函数的参数是结构体变量,然后对参数重新赋值并返回,所以该题目的答案为B选项。
转载请注明原文地址:https://kaotiyun.com/show/Botp777K
0

最新回复(0)