void swap( int *a, int *b)
{
int t=*a;
*a=*b;
*b=t;
}
int main()
{
int x=1;
int y=2;
int *a=&x;
int *b=&y;
printf("%d %d\n", *a, *b);
swap(a,b);
printf("%d %d\n", *a, *b);
return 0;
}
kcsdev:/home/jmcnama> cc t.c
kcsdev:/home/jmcnama> ./a.out
1 2
2 1
FWIW. I think he meant to swap what the pointers were "aimed" at. Not the actual pointers themselves. But it doesn't matter....