I typed these code. However, the output is beyond my expectations.
#define SWAP(x,y) {x=x^y;y=x^y;x=x^y;}
#define SWAP2(x,y) {x=x+y;y=x-y;x=x-y;}
int main()
{
int ia[] = { 1, 10, 1 };
SWAP(ia[0], ia[0]); // the resutl is ia[0] = 0
SWAP(ia[1], ia[2]); // work fine
SWAP2(ia[1], ia[1]) // the result is ia[0] = 0
}
Anyone can help me? Any help will be appreciated.