swapping variables

cottrell at nbs-vms.ARPA cottrell at nbs-vms.ARPA
Tue Feb 5 08:12:36 AEST 1985


/*
> >	 int ptr[]   <=>   int *ptr
> 
> Oo, oo!  This brings to mind a useful language extension:
> 
> 	a <=> b;
> 
> for exchanging the contents of a and b.  How often have you written:
> 
> 	{	register type	t;
> 
> 		t = a;
> 		a = b;
> 		b = t;
> 	}
Rarely. I use:	`a ^= b; b ^= a; a ^= b;' Only worx for integer types.
*/



More information about the Comp.lang.c mailing list