Redirection question

Michael Salmon epames at eos.ericsson.se
Tue Nov 13 18:33:15 AEST 1990


In article <roarment.658423394 at faui09> roarment at faui09.informatik.uni-erlangen.de
(Roberto Armenti) writes:
>Is there a _portable_ way to recognize whether input comes from
>stdin or from another stream ?
>
>The solution should at least work on UNIX _AND_ MS-DOS, so i'm looking for
>a _portable_ implementation.

isatty(fileno(stdin)) should do what you want. I have seen it implemented
on Unix, MS_DOS and CP/M systems but I can't say how portable it is.
I also find it very handy to determine when to give a usage message
when file names are omitted from the command line, I hate programmes
that do nothing when I make a mistake.

Michael Salmon
L.M.Ericsson
Stockholm



More information about the Comp.lang.c mailing list