Stdio FRead

utzoo!decvax!ucbvax!dcrocker at udel utzoo!decvax!ucbvax!dcrocker at udel
Tue Jul 21 16:19:18 AEST 1981


From:      Dave Crocker <dcrocker at 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





More information about the Comp.unix.wizards mailing list