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

admin2018-09-26  23

问题 有以下程序
    #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,’’Wangaeng’’);t.c=1220.0;return t;}
    程序运行后的输出结果是(    )。

选项 A、1001,ZhangDa,1098.0
B、1002,ZhangDa,1220.0
C、1001,WartgPeng,1098.0
D、1002,WangPeng,1220.0

答案D

解析 在主函数中定义结构体A的变量a,并对其赋初值,再调用函数f(a),在函数f(a)中对结构体变量a的各个成员重新进行了赋值操作,并把其值返回在屏幕上输出。
转载请注明原文地址:https://jikaoti.com/ti/jEa0FFFM
0

随机试题
最新回复(0)