有以下程序: #include #include struet A { int a;ehar b[10];double c;}; struet A f(struet A t); main() { struet A a={10

admin2021-06-15  23

问题 有以下程序:
  #include
  #include
  struet A
  {  int a;ehar b[10];double c;};
  struet A f(struet A t);
  main()
  {  struet A a={1001,"ZhangDa",1098.0};
    a=f(a);printf("%d,%s,%6.If\n",a.a,a.b,a.c);
    }
    struet A f(struet A t)
    {t.a=1002;strcpy(t.b,"ChangRong");t.c=1202.0;return t;}
    程序运行后的输出结果是(    )。

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

答案D

解析 函数f对结构体成员进行修改,并返回新的结构体;main函数先定义了一个结构体变量a并为它赋初值,然后调用函数f修改结构体变量的成员值,最后输出新的结构体变量成员。
转载请注明原文地址:https://jikaoti.com/ti/ZCz0FFFM
0

随机试题
最新回复(0)