分类: LINUX
2011-06-08 08:58:08
Write a small C program, which while compiling takes another program from input terminal, and on running gives the result for the second program. (NOTE: The key is, think UNIX).At first it looked like a strange puzzle. How can a C code force the compiler to request for input while it is already compiling the code? After a little thinking, the solution became obvious.
Update: I have realized it and many people have pointed it out to me that the solution doesn't take input while compiling. Instead, it takes input while pre-processing. Unfortunately, I didn't think of this minor but important difference while writing this blog post. I could have changed the subject after I realized it but unfortunately, this blogging application doesn't allow me to change the URL. Hence, I left it unchanged.