"William Gray" <billy.zophar@gmail.com> writes:
> ... And in the case
> that fread() pulls in less data than requested, that means the next call to
> fread() should return zero, right?
Wouldn't count on that, particularly not when reading from an
interactive device. You are more likely to get a line per call.
What's bothering me about your code is that it assumes there are
exactly STDIN_BLOCK bytes available in the buffer when you call
fread, and the code does nothing that guarantees that. Personally
I'd have used "size - offset" as the fread length parameter and not
had to worry.
regards, tom lane