Monthly Archives: October 2012

C code that could get you fired

Here’s another stupid C trick I’ve carried around in my brain for a while: #define sizeof(x) (rand() % 20 + 1) The mod and addition are to give a random number in the range from 1 to 21. This can … Continue reading

Leave a Comment

Filed under code

Wherein 2 is shown to be equal to 1

Here’s a little maths trick I have for some reason carried around in my brain for years: Dividing through by the common Why this is possible is left as an excercise for the reader 🙂

4 Comments

Filed under geekery

C code you should never use in production

I’ve been meaning to write this little trick down for a while, so while I remember to, here’s a stupid little C trick which amuses me. Consider a C array: char array[3] = {1,2,3}; To access element 3, you would … Continue reading

5 Comments

Filed under code