??? 06/22/07 19:54 Read: times |
#141165 - Non kosher C Responding to: ???'s previous message |
Russ Cooper said:
x^=y^=x^=y; x and y are both integer types of the same width. What does this line of C code do, and how is it better than the more obvious method that's often used? What does it do? It gives any decent compiler fits, that's what it does. Nevertheless, the default behavior of most C compilers is to generate code that swaps the values of x and y, without using a temporary variable. This trick, from finite automata class if I recall correctly, is suitable for assembly language, but no C compiler is guaranteed to generate the code you think it will. |