编写函数,分别利用指针传递参数,实现两个字符串变量值的交换

发布时间:2021-03-09 21:12:45

编写函数,分别利用指针传递参数,实现两个字符串变量值的交换

网友回答

void Exchg2(int *px,int *py)
{ int tmp = *px;
*px = *py;
*py = tmp;
printf(*px = %d, *py = %d.\n, *px, *py);
}main()
{ int a = 'c';
int b = 'd';
Exchg2(&a, &b);
printf(a = %d, b = %d.\n, a, b);
return(0);
}这是整型变量的例子,稍加改动就可以变成字符串,希望可以帮助到你!
以上问题属网友观点,不代表本站立场,仅供参考!