有以下程序: #include <stdio.h> struct STU { char name[10]; int num; }; void f1(struct STU c) { struct ST

admin2009-01-15  19

问题 有以下程序:    #include   <stdio.h>    struct STU    {  char name[10];       int num;    };    void f1(struct STU c)    {   struct STU b={"LiSiGuo",2042};        c=b;    }    void f2(struct STU *c)    {   struct STU b={"SanDan",2044};        *c=b;    }    main()    {  struct STU a={"YangSan",2041}, b={"WangYin",2043};       f1(a);  f2(&b);       printf("%d%d\n",a.num,b.hum);    }    执行后的输出结果是(    )。

选项 A、2041 2044
B、2041 2043
C、2042 2044
D、2042 2043

答案1

解析 f2函数传递的是变量的地址,可以实现数据的交换,而f1函数传递的是值,调用完 f1函数后,c的值改变了,但main函数中的a值并未改变。
转载请注明原文地址:https://kaotiyun.com/show/LpHp777K
0

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