A curious feature: howto swap numeric variables ezpz without a buffer using the bitwise XOR operation (bitwise exclusive OR):
#include <stdio.h>
int main(void)
{
int a = 3;
int b = 5;
printf("a = %d, b = %d\n", a, b);
a = a ^ b;
// a = 11
// b = 101
// a^b = 110
printf("a = %d, b = %d\n", a, b);
b = a ^ b;
// a = 110
// b = 101
// a^b = 011
printf("a = %d, b = %d\n", a, b);
a = a ^ b;
// a = 110
// b = 011
// a^b = 101
printf("a = %d, b = %d\n", a, b);
return 0;
}
What the foo! 😀