Funny code snippets - Introduction

This page is donated to the wonderful world of those little pieces of code that make your life as a programmer funnier (or not :-)

I will show examples of interesting (but working) code, other examples that don't work, even if the reason, why the code does not work is not visible on the first glance.

There is only one rule for incorporating a piece of code into the pages: It must be funny or extraordinal. I'm the only judge - if you don't like my stuff, go away and make your own.

Some words on the history of this page: A long time ago, when I worked as a freelancer for a company that sold automatic testing machines, we had a big library (> 100.000 lines of code) written in turbo pascal that included a real time multitasking kernel and some other - useful but complicated - stuff. Some day, after a few hours of bug hunting, one of my collegues (who came from the same university) reminded me of one of our math professors. He had something, he named "Mathematisches Gruselkabinett" where he kept all the brilliant pieces of work that his students sweated out in the exams. One example I remember was a student who reduced the formula

        sin x
        si x
where sin is sinus and si is the signum function like this:

        sin x       n x
       -------  =  -----  = n
         si x        x

At that time, we had the idea to create a "Gruselkabinett" for programmers. Much of the code that we collected could only be understood in the context of the library we used. Much other code got lost over the years.

Then, a few month ago, I decided to create something like this "Gruselkabinett" on the web and put in there all those pieces of code that are to valuable to forget. I will add or remove code snippets to this page whenever I like to do so. As stated above, there is no other rule than my own sense of humor and/or good programming style.

I have no special preference for any programming language (I'm using mostly C++, some C code, Pascal, assembler...), so I will mix examples using different languages freely. Regardless of my preferences, you will probably notice, that C is the language of choice if you want to write really nasty code. If the capabilities of the bare compiler aren't enough, one may add precompiler macros that will give the most undetectable errors ever.

But now, have fun!

Go back.

snintro.html; last change: 01-Aug-98