Odd C interview question
- by Brennan Vincent
Hi guys. I found this problem on a site full of interview questions, and was stumped by it. Is there some preprocessor directive that allows one to read from standard input during compilation?
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). Suppose, the program is 1.c Then, while compiling
$ cc -o 1 1.c
int main() { printf("Hello World\n"); } ^D
$ ./1
Hello World