swap (int *a, int *b) {
*a ^= *b;
*b ^= *a;
*a ^= *b;
}
int c = 13;
int d = 27;
swap (&c, &d); /*c is now 27 and d is now 13 */
Note: there is no call-by-reference in C. In C++:
void swap (int &a, int &b)
{
. int tmp;
. tmp = a;
. a = b;
. b = tmp;
}