[lore] C hacks

David Basden davidb at ucc.gu.uwa.edu.au
Fri Mar 28 00:50:11 WST 2008


I was thinking that maybe people are just writing C that is either
too readable, too inefficient or both. Maybe a connect-the-equivilent-
code puzzle or something?

Here is just a quick one 'cause I'm beyond tired, but please add to it;
I don't know if the third works, and might not be a good idea to let out
in public even if it does...

while (*a++ == *b++);	 strcpy(b,a);

a ^= b ^= a;			int tmp = a;
                                a = b;
                                b = a;

a >> 1;				a = a / 2;

b = (((a - b) & (1<<(sizeof(int)-1))) && b) || a; 	if (a > b) b = a;

a << 3;				a =  a * 8;

1 << a;				(int) pow((int) a, 2);

a & 1;				a % 2;

a & 7;				a % 8;

(a & 15) || ++b;		if (a % 16 == 0) 
					b = b + 1;



More information about the lore mailing list