有以下程序 #include<stdio.h> void f(int*p,int*q); main() {int m=1,n=2,*r=&m; f(r,&n);printf("%d,%d",m,n); void f(int*p,int*q) { p=p+1

admin2018-11-21  22

问题 有以下程序
#include<stdio.h>
void f(int*p,int*q);
main()
{int m=1,n=2,*r=&m;
f(r,&n);printf("%d,%d",m,n);
void f(int*p,int*q)
{
p=p+1;*q=*q+1;
}
程序运行后的输出结果是

选项 A、2,3
B、1,3
C、1,4
D、1,2

答案B

解析 本题考查函数的调用与指针。fun()函数的作用是:使指针p指向原来所指变量的下一个变量,使q指针指向的值加1。主函数中,指针r指向m,调用fun()函数的结果是,使r指向地址位于m后面的变量,使位于n的地址上的变量(就是n)的值加1,因此,结果为1,3。
转载请注明原文地址:https://kaotiyun.com/show/nlxp777K
0

最新回复(0)