C语言:我使用子函数将指针变量中的指针进行交换,但是为什么所指向的变量却没有变?程序如下:
voidhuan(int*a,int*b){int*temp;temp=a;a=b;b=temp;}voidmain(){inta,b;int*pa;int*pb;sca...
void huan(int* a, int* b)
{
int* temp;
temp = a;
a = b;
b = temp;
}
void main()
{
int a, b;
int* pa;
int* pb;
scanf("%d %d", &a, &b);
pa = &a;
pb = &b;
huan(pa, pb);
printf("%d %d %d\n", *pa, *pb);
system("pause");
} 展开
{
int* temp;
temp = a;
a = b;
b = temp;
}
void main()
{
int a, b;
int* pa;
int* pb;
scanf("%d %d", &a, &b);
pa = &a;
pb = &b;
huan(pa, pb);
printf("%d %d %d\n", *pa, *pb);
system("pause");
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询