#include <stdio.h>
//通过指针并利用函数交换两个数的值
void Swap(int* pa, int* pb)
{
int z = 0;
z = *pa;
*pa = *pb;
*pb = z;
}
int main()
{
int a, b;
a = 10;
b = 20;
printf("交换前a=%d,b=%d\n", a, b);
Swap(&a, &b);
printf("交换后a=%d,b=%d\n", a, b);
//初识指针
int m = 10;
int* pa = &m;
*pa = 20;
printf("m = %d", m);
return 0;
}
vs2022
注释: 先CTRL+K,然后CTRL+C
取消注释: 先CTRL+K,然后CTRL+U