Detect where input comes from: stdin or using "<"
Posted on 2004-09-09
My program recieves commands (one by one), and executes them.
It can be ran with a filename (./my_prog 01.in),
or without parameters (in this case stdin will be used).
If the input comes from a file, I print the command on screen.
If the input comes from stdin, I don't print (because it's already on screen).
The problem is that one can run the program this way:
./my_prog < 01.in
The program will know it recieves commands not from a file, and won't print
the command, but it won't be visible on screen too.
How can I detect if the input comes from stdin or using "<"?