2015-05-27

C: fun on the 404 page of stackoverflow

I found this fun on the SO's 404 page:
Of course, it is a pretty lightly obfuscated C code printing out "404".

This is what will get effectively compiled and executed (you can verify with gcc -E -P):
main(){putchar(4+putchar(putchar(52)-4));return 0;};exit();
As putc returns the character it printed out, the magic is easy:
  1. Print the character dec 52  (which is the digit four)
  2. Print the character dec 52-4 = dec 48 (which is the digit zero)
  3. Print the character dec 48+4 = dec 52 again

No comments :

Post a Comment