MCENANEY WILLIAM J wrote:
> In his book "Advanced Programming in a Unix Envuronment," Richard Stevens
> writes that fgets() runs faster than fgetc(). That's for two reasons, I
> think. First, fgets() reads a line when you call it. Second, since it
> does re a line when you call it, it requires fewer system calls than
> fgetc() would require. I'm pretty sure about this, but it's probably a
> good idea to check with our friends. They know more than I do.
If the stream being read is a conventional file (as opposed to a
character device, pipe, fifo, or socket), then all stdio calls read
data in fixed size chunks (default on Intel-Linux-glibc2 is 8K), so
using either fgetc() or fgets() will result in the same number of
system calls.
If the stream refers to something other than a conventional file, then
the underlying read() call may return less than than the buffer size.
Usually it will read the amount of data currently available. For a
terminal, this is typcially a single line.
--
Glynn Clements <[EMAIL PROTECTED]>