Sensing STDOUT redirection in C

Adrian Collins collinsa at p4.cs.man.ac.uk
Mon Apr 15 23:11:23 AEST 1991


I am currently writing a program for the PC using C.  I need to be able
to sense whether STDOUT has been redirected on the command line.  In the
case where the output has not been redirected the program opens a text
window and displays the info in that window, but if output redirection
was used I want the program to output to STDOUT as it should assume that
the output is to be sent to a file.

Does anybody know how to sense whether output redirection has been used
on the command line?

Adrian

---
Adrian Collins                              collinsa at uk.ac.man.cs.p4
Department of Computer Science              a.m.collins at uk.ac.mcc
University of Manchester
Manchester,                                 "Let me face the peril"
UK.                                         "No, it's too perilous!"
                                                    - The Holy Grail



More information about the Comp.lang.c mailing list