Programming Puzzle #1

06 Dec

Consider the following program written in pure C89 on a 32-bit OS:

#define define include
#define include define
#include <stdio.h>
#include <stdlib.h>
*int, char*??/
/)??<char* c;c = call??/
oc(10, sizeof(*c))//??/
c = "hello, world" ; #define int char
;int x=(sizeof(int)<<sizeof(c))+(sizeof(int)>>sizeof(*c)), i=??/
* c;do c??(++i??)="0123456789??/
abcdef"??(x & 0xf??);while(x>>=sizeof(i));for(;x??!i;--i)putchar(c??(i??));??>

Two questions (solve without computer):

  1. Does it compile (w/ appropriate flags)? [Tested on GCC 4]
  2. What is the output?

Just a few tricks, but shouldn’t be too hard to solve. I’ll give the answer in the coming days.

1 Comment

Posted by on December 6, 2010 in Uncategorized


Tags: , , ,

One response to “Programming Puzzle #1

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: