Text File

Aucbvax.2388 fa.unix-wizards utzoo!decvax!ucbvax!dcrocker@udel Tue Jul 21 16:19:18 1981 Stdio FRead From: Dave Crocker <DCROCKER@UDEL> The documentation for fread() lies, a little bit. It claims to return a zero on error or end-of-file. When reading from a terminal, this will usually not be true.

If you try to read some arbitrarily large amount, fread will keep doing read() calls on the terminal, until the count is filled or until a control-D at the beginning of the line. If you have some text (i.e., the control-D is not done on the first input line), then fread() returns the count of text already acquired.

The next fread() will simply generate another read() on the terminal. I.e., feof(stdin) and ferror(stdin) are not done when fread starts.

Dave

----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen <jgoerzen@complete.org> of http://communication.ucsd.edu/A-News/

This Usenet Oldnews Archive article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.