Odd C interview question
        Posted  
        
            by 
                Brennan Vincent
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Brennan Vincent
        
        
        
        Published on 2011-01-14T03:24:28Z
        Indexed on 
            2011/01/14
            3:53 UTC
        
        
        Read the original article
        Hit count: 312
        
c
|interview-questions
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
© Stack Overflow or respective owner