Swap 函数
改变指针的指向
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
void swap(int ** a, int ** b)
{
int *tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
int main()
{
int a , b;
int *tp, *tq;
int **p , **q;
a = 1;
b = 2;
tp = &a;
p = &tp;
tq = &b;
q = &tq;
swap( p, q);
printf("%d %d", *tp , *tq);
}
2009-07-06 23:40:33