Brain Teaser

Peter da Silva peter at ficc.uu.net
Fri Mar 30 12:01:19 AEST 1990


swap(x,y,len)
char *x, *y;
size_t len;
{
	while(len>0) {
		*x^=*y; *y^=*x; *x^=*y;
		x++; y++; len--;
	}
}

Usage: swap(x, y, sizeof(x));

Sort of a pyrrhic victory, though.
-- 
 _--_|\  `-_-' Peter da Silva. +1 713 274 5180. <peter at ficc.uu.net>.
/      \  'U`
\_.--._/
      v



More information about the Comp.lang.c mailing list