i am trying to understand macro in c. i had found this program as a question to extract the error obviously it need to swap the numbers using exclusive or (i can not also understand why using xor to swap)
#include <stdio.h>
#include <stdlib.h>
#define SWAP(a, b) { a ^= b; b ^= a; a ^= b;}
int main(void) {
int x = 10;
int y = 5;
int z = 4;
if (x < 0)
SWAP(x, y);
else
SWAP(x, z);
}
the compiler popped an error to include if before else. but obviously there is an if before else i want to understand the reason behind this.