10,
sizeof(int),
(int ()(const void , const void *)) intcompare
);
As an impractical example, you can create a pointer to, for example printf(), with
extern int printf(const char*,...);
void f = (void)printf;
You can then call printf through a properly-cast pointer, in this manner:
((int()(const char*,...))f)("Bite my shorts. Also my chars
and ints\n");
Some Light Relief—The Inter national Obfuscated C Code Competition
The C language combines all the power of assembly language with all the ease-of-use of assembly
language.
—Ancient Peasant Proverb
It's possible to abuse any programming language. Most good programmers can write programs that are
so intense, it hurts your eyes just to look at them. Code that you can proudly show to programmers in
the next office, and challenge them to figure out what it does. Code that, six months after writing it,
you can't figure out what it does. You can write these kinds of programs in any language; it just seems
to be easier with C.
The International Obfuscated C Code Competition (IOCCC) is an annual contest run since 1984 over
USENET by Landon Curt Noll and Larry Bassel. It started when Landon looked at the source for the
Bourne shell and decided, "Nah! It's just too outré." He began to wonder how far you could go if you
actively tried to make C code look confusing, rather than just achieving this as an accidental side
effect.
The competition has become an annual tradition. Entries are accepted in Winter, judging takes place
over the Spring, and the winners are announced at the Summer Usenix conference. There are usually
about ten categories of winner: "strangest abuse of the rules," "most creative source layout," "best one-
liner," and so on. The overall "best of show" winner is whoever produces the most unreadable, and
bizarre (but working) C program.
The IOCCC is a lot of fun, and can extend your knowledge in surprising ways, whether you enter or
merely analyze the prize-winning code afterward. For example, in 1987, David Korn of Bell Labs
submitted this winning entry: