C Programming - XOR Bitwise Operation
问题 What operation does the following ‘C’ statement perform? star = star ^ 0b00100100; (A) Toggles bits 2 and 5 of the variable star. (B) Clears all bits except bits 2 and 5 of the variable star. (C) Sets all bits except bits 2 and 5 of the variable star. (D) Multiplies value in the variable star with 0b00100100. I'm still clueless about this. Can someone help me out? 回答1: XOR operator (also called "logical addition") is defined like this: a b a^b ----------- 0 0 0 0 1 1 1 0 1 1 1 0 So a^0 leaves