问题 单项选择题

有以下程序:
#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

答案

参考答案:A

解析: f2函数传递的是变量的地址,可以实现数据的交换,而f1函数传递的是值,调用完 f1函数后,c的值改变了,但main函数中的a值并未改变。

选择题
单项选择题