//printf语句写到main函数里
#include <stdio.h>
void Swap_error1(int a,int b){
int tmp;
tmp = a;
a = b;
b = tmp;
}
void Swap_error2(int *a,int *b) //仅仅只是a和b的地址交换,然后……没有然后了
{
int *tmp;
tmp = a;
a = b;
b =b;
}
void Swap_error3(int *a,int *b)
{
int *tmp;//野指针,悬挂指针,自己本身没有访问权限
*tmp =*a;
*a = *b;
*b = *tmp;
}
//被调用函数要想改变调用函数里的数值,必须要:
//1、传指针 2、解引用(间接访问符)
void Swap(int *a,int *b)//用int的变量来存储进行a和b的地址交换,并且解引用{
int tmp;
tmp = *a;
*a = *b;
*b =tmp;
}
int main()
{
int a = 10;
int b = 20;
Swap(&a,&b);
printf("%d,%d\n",a,b);
return 0;
}