fscanf(), fgets(), fflush() problem

Robert Earl chupchup at piggy.ucsb.edu
Tue Jun 25 10:57:48 AEST 1991


In article <1991Jun24.132920.4956 at iccgcc.decnet.ab.com> bush at iccgcc.decnet.ab.com writes:

|   The fflush() function is used only to flush output buffers to disk.  When 
|   working with files, output information goes into a disk buffer, which when
|   full, is flushed to disk by the operating system.  All that fflush() does
|   is to allow you to force the operating system to write a disk buffer to
|   disk when it is not completely full.

Wrong: fflush() forces the stdio implementation to flush its internal buffer,
whether it be block-buffered, line-by-line, or none, by doing (for example) a
write() system call.  After that, the operating system can do what it likes in
buffering data to be written to a terminal, file, pipe, or whatever.


An alternative to using scanf() and fscanf() on interactive input is to use
fgets(), and then sscanf() the resulting string.  I think this is an FAQ.

--
______________________________________________________________________
			\
 robert earl		/	"Love is a many splintered thing"
 rearl at piggy.ucsb.edu	\		--Sisters of Mercy



More information about the Comp.lang.c mailing list