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’?
5 responses so far ↓
1 CH Gowri Kumar // Nov 23, 2007 at 9:08 am
On UNIX a.c is :
#include
And on Windows/MS-DOS I think it is
#include
2 CH Gowri Kumar // Dec 6, 2007 at 11:04 am
The solution is eaten up in html.
Let me give it a second try:
#include </dev/tty>
3 Pramode C.E // Dec 20, 2007 at 11:19 am
That’s it!
4 sowmya.s // Feb 29, 2008 at 6:20 am
hi pramode ,
can u plz explain that line
#include</dev/tty>
5 Pramode C.E // Mar 10, 2008 at 4:10 am
We are simply including /dev/tty, which is our `console’.
Leave a Comment