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

admin2017-07-05  19

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

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

答案A

解析 本题主要考查的是函数调用时参数之间的传递问题。在C语言中参数之间的传递是传值,也就是把实参的值复制一份传递给形参,而实参的值不发生变化。所以对于本题来说,在主函数中执行f(a),把结构体变量a的值复制一份传递给形参变量t,而实参变量a的值保持不变。
转载请注明原文地址:https://kaotiyun.com/show/AdDp777K
0

最新回复(0)