Swapping Values with XOR [duplicate]
问题 This question already has answers here : Sequence Point - Xor Swap on Array get wrong result (1 answer) How does XOR variable swapping work? (9 answers) Closed 5 years ago . What is the difference between these two macros? #define swap(a, b) (((a) ^ (b)) && ((a) ^= (b) ^= (a) ^= (b))) Or #define swap(a, b) (((a) ^ (b)) && ((b) ^= (a) ^= (b), (a) ^= (b))) I saw the second macro here but couldn't understand why it wasn't written like the first one? Is there a special reason that I missed? 回答1: