利用指针交换两个值(C语言)
程序员文章站
2024-03-07 19:31:45
...
# include <stdio.h>
void exchange(int * p, int * q)
{
int t ;
t = *p ;
*p = *q ;
*q = t;
}
int main(void)
{
int a = 3;
int b = 5;
exchange(&a, &b);
printf("a= %d , b = %d", a, b);
return 0;
}
上一篇: 指针的相关知识