猿问

关于指针的小问题

include <stdio.h>

void main()

{

void swap(int x,int *y);

int a=5,b=10;

swap(a,&b);

printf("%d,%d\n",a,b);

}

void swap(int x,int *y)

{

int t;

t=x;

x=*y;

*y=t;

}

运行结果5,5

如果a=8其他不变   结果是8,8

 

swap这个函数作用是把a,b互换的意思吧?

不解


慕的地10843
浏览 687回答 1
1回答
随时随地看视频慕课网APP
我要回答