有以下程序 #include #include void fun( int *p1, int *p2, int *s) { s=( int*)calloc(1,sizeof(int)); *s=*p1+*p2; free(s); } main()

admin2019-06-09  23

问题 有以下程序
#include
#include
void  fun( int *p1, int *p2, int *s)
{  s=( int*)calloc(1,sizeof(int));
*s=*p1+*p2;
free(s);
}
main()
{  int  a[2]={1,2}, b[2]={40,50},*q=a;
fun(a,b,q);
printf("%d\n", *q);
}
程序运行后的输出结果是

选项 A、42
B、 41
C、1
D、0

答案C

解析 本题考查把数组名作为函数参数,执行fun函数后,s的值并没有发生变化,仍然是指向a,所以输出结果为1,选项C正确。
转载请注明原文地址:https://kaotiyun.com/show/AxRp777K
0

最新回复(0)