Programming Puzzle 1
Dec 6, 2010 · 1 minute readConsider the following program written in pure C89 on a 32-bit OS:
#define define include
#define include define
#include <stdio.h>
#include <stdlib.h>
main(/??/
*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):
- Does it compile (w/ appropriate flags)? [Tested on GCC 4]
- 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.