using ^= to swap two integers

J.WOOD jlw at ariel.UUCP
Tue Feb 12 12:32:32 AEST 1985


Regarding swapping via the xor operation as in:


	b ^= a ^= b ^= a;
	
be careful that a and b are not at the same address
as when using pointers.  In that case the value(s) are (both)
set to zero.  I got burned on this once.



					Joseph L. Wood, III
					AT&T Information Systems
					Laboratories, Holmdel
					(201) 834-3759
					ariel!jlw



More information about the Comp.lang.c mailing list