Newsgroups: comp.programming,comp.os.msdos.djgpp From: smryan AT netcom DOT com (!@?*$%) Subject: Re: standard input and files Message-ID: Sender: smryan AT netcom3 DOT netcom DOT com Organization: The Programmer formerly known as S M Ryan References: Date: Sun, 13 Oct 1996 19:23:23 GMT Lines: 23 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp > from standard input or from a file. Like the more command ( on unix ) or > grep or something. I also want to use ifstreams to do the input. As a side note, more uses two input files, stdin and the controlling terminal of the session. > Can I assume that standard input is always file descriptor 0, or Yes. (stdio makes the same assumption.) In Unix, if descriptor 0 is open then whatever file it is, it is standard input. Descriptor 1 is always stdout, descriptor 2 is always stderr. The descriptors aren't sacred: you close them and open some other file there if you want, but every shell guarentees 0, 1, and 2 are open, 0 is readable, 1 and 2 are writable. It is possible that if your program is execed from a non-shell, descriptor 0 could be closed or not readable, but that would then be a violation of your program's calling conventions. -- The winter ceased its weary grip | smryan AT netcom DOT com PO Box 1563 when soft and sudden sunbeams slip | Cupertino, California and etch away the ice and gray, | (xxx)xxx-xxxx 95015 with life to soul and song to lip. | I don't use no smileys