Originally published on: Tue, 21 Apr 2009 23:51:27 +0000
I had written a little C program a while back for the 19th annual International Obfuscated C Coding contest.
Not only did my code not win ... it didn't even warrant an entry in the honorable mentions or anything like that. If you look at the winners and look back at my code, you'll immediately see why; the winners and the runners-up were much more creative than my effort.
Rather than get lost in obscurity, I felt that my entry needed to be published, so it has been given the honor of appearing in my first public blog post.
Everyone, please meet lawless.c ... a ROT-13 encoder/decoder that encodes/decodes one line at a time:
The rules for the 19th annual competition had noted that C preprocessor tricks might just as well not be used as each entry would be run through the preprocessor for expansion.
Here's what the above code would look like after preprocessing;
I tried to use preprocessor abuse to get my cutesy "I slit the sheet..." lines into view ... but the core of the processing was done via indirect invocation of entries in an array of function-pointers.
It was a fun exercise that I hope to revisit with more seriousness in the future.
Unless otherwise noted, all code and text entries are Copyright ©2009 by James K. Lawless
Save to del.icio.us
Save to StumbleUpon
Digg it
Save to Reddit
Share on Facebook
Share on Twitter
More bookmarks
Subscribe!
Auto Save Clipboard Images Redux
Extending SpiderMonkey JavaScript on Windows
Rhino JavaScript to EXE with launch4j
Compiling Rhino JavaScript to Java
Directory Traversal in Rhino JavaScript
A Command-Line MP3 Player for Windows
Auto Save Images from the Clipboard
Java in a Windows EXE with launch4j
An Interview with Tom Zimmer: Forth System Developer
Setting Windows Console Text Colors in C
A Simple Media Control Interface Script Processor
BSave and BLoad for the Commodore 64
Directory Traversal in Rhino JavaScript
Setting Text Color in a Batch File
BPL: Batch Programming Language Interpreter
Choose your own Adventure with Sinatra
MicroISV on a Shoestring
DadHacker
The Bottom Feeder
Writin' That Code!
The Recursive ISV
The Thomsen Blog
Prototypically Speaking
The Reinvigorated Programmer