<=> and obfuscation

Yogesh K Gupta gupta at asgb.UUCP
Tue Feb 12 02:53:48 AEST 1985


> > 	To exchange two items without an intermediate variable, try:
> > 
> > 	b ^= a ^= b ^= a
>
>  This works for integer variables only.

In C, the ^ is a bitwise operator. Thus,
	b ^= a ^= b ^= a
will exchange the bit patterns in the two variables.
As long as the two variables are of the SAME type, the values will be
swapped.

As to the efficiency and programming style ...

-- 
Yogesh Gupta                           Advanced Systems Group,
{sdcrdcf, sdcsvax}!bmcg!asgb!gupta     Burroughs Corp., Boulder, CO.
--------------------------------------------------------------------
	All opinions contained in this message are my own and do not
	reflect those of my employer or the plant on my desk.



More information about the Comp.lang.c mailing list