Possible Duplicate:
Detect if stdin is a terminal or pipe in C/C++/Qt?
Consider we got a small program which takes some standard C input.
I would like to know if the user is using input redirection, for example like this:
./programm < in.txt
Is there a way to detect this way of input redirecting in the program?
There’s no portable way to do that, since C++ says nothing about where
cincomes from. On a Posix system, you can test whether or notcincomes from a terminal or is redirected usingisatty, something like this: