Obfuscated RPN calculator

August 29, 2010

A while back I got quite bored, and decided to try my hand at code obfuscation. What you see below is the result of my first attempt. It’s a RPN calculator that supports basic arithmetic (only a single operation per line, unfortunately). In the future I want to do something a bit more complex, i.e. code that doubles as some pretty ASCII art.

#include <stdio.h>

#define t
#define a t \
typedef t t t
#define b t ;
#define B t \
#define c t \
w,sizeof w, \
stdin t b t b
#define d t {
#define D ) \
d switch(z) d
#define e t \
case t t t t
#define E t \
if(sscanf(w \
,"%d %d %c" t
#define k }t\
}}} b t b t b
#define o(n)\
"\n",x n y) \
b break b t t

a int f b a char F t
b f main()d F w[200]b
B c)) d f x,y b F z t
E,&x,&y,&z)==3 D e'+'
:o(+)e'-':o(-)e'*': t
o(*)e'/':o(/) b t b k