C Puzzle

Published on: 2007-6-26

Home | Archive

C Puzzle


Here is a C puzzle I got from Bestin: You have a magical program `a.c'. When you type `cc a.c', your compiler appears to hang (ie, you don't get back the prompt). Now,during this time, you will be able to type any program `b.c' in the standard input and type Ctrl-D. Once you do this, you get back the prompt. Now, you type `a.out' and magic, what you get will be the output of program `b.c'! Question is, what is this program `a.c'?

CH Gowri Kumar

Fri Nov 23 09:08:39 2007

On UNIX a.c is : #include And on Windows/MS-DOS I think it is #include

CH Gowri Kumar

Thu Dec 6 11:04:05 2007

The solution is eaten up in html. Let me give it a second try: #include &lt/dev/tty&gt

Pramode C.E

Thu Dec 20 11:19:36 2007

That's it!


Fri Feb 29 06:20:45 2008

hi pramode , can u plz explain that line #include&lt/dev/tty&gt

Pramode C.E

Mon Mar 10 04:10:26 2008

We are simply including /dev/tty, which is our `console'.