1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# include <stdio.h>


void huhuan03(int*, int*); //声明不用写形参
void huhuan01(int, int);
void huhuan02(int*, int*);

int main(void)
{
int a = 3;
int b = 5;

huhuan03(&a, &b); //huhuan02(*p, *q); 错误 huhuan02(*a, *b);也是错误的
printf("a = %d, b = %d\n", a, b);

return 0;



}

//可以完成互换功能
void huhuan03(int* p, int* q)
{

int t; //如果要互换*p和*q的值,则t必须定义成int,不能定义成int *,否则语法出错.
t = *p; //p是int *, *p是int
*p = *q;
*q = t;

return;
}


//不能完成互换功能
void huhuan01(int a, int b)
{
int t;
t = a;
a = b;
b = t;

return;
}


//不能完成互换功能
void huhuan02(int * p, int * q)
{
int * t; //如果要互换p和q的值,则t必须是int *,不能是int.类型要一致否则出错
t = p;
p = q;
q = t;

return;
}