Repost. (I know op's post is about xor swap but funny)
void xorSwap (int* x, int* y) {
if (x != y) {
*x ^= *y;
*y ^= *x;
*x ^= *y;
}
}
One of the most clever and the worst performing methods of swapping 2 numbers.
Came across this gem as I attempted to learn prog from scratch, and got some good flashbacks to my second year when I found this trick, worked out a couple examples, and was adamant on using this everywhere I could!