When I started learning to program in C, I was fortunate enough to stumble across a gem of a book called “Expert C Programming: Deep C Secrets.” It has a picture of a selakant on the cover. The author has a great sense of humor, but most importantly it has all kinds of good tips for beginner C programmers looking to improve their knowledge.
In one particular chapter, he talks about the IOCCC. The first piece of code he writes about is the following was the winning entry from 1987 by David Korn:
main() { printf(&unix["\021%six\012\0"], (unix)["have"] + "fun" - 0x60); }
I actually compiled and ran it at the time and it prints the word “unix.” I was never able to figure out how the whole thing worked out though. Time passed and I forgot about it.
Well, not entirely. Today, while working on a piece of code, I finally thought to google the thing today. Lo and behold, there is an explanation for how it works. If you’re curious, here it is.