Pages

Thursday, March 03, 2005

Obfuscated "C" code

Found this interesting piece of C code somewhere on internet. Of course it compiles and prints out 3.141 on console; And it is not so hard to guess how the code in F_OO() gets executed
Govinda% more fun.c
#include <stdio.h>

#define _ F-->00 || F-OO--;
long F=00,OO=00;

void F_OO() {
_-_-_-_
_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_-_-_-_-_
_-_-_-_-_-_-_-_
_-_-_-_
}

main(){
F_OO();
printf("%1.3f\n", 4.*-F/OO/OO);
}

Govinda % cc -o fun fun.c
Govinda % ./fun
3.141

1 comment: