Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!ucsd!hub.ucsb.edu!chupchup From: chupchup@piggy.ucsb.edu (Robert Earl) Newsgroups: comp.lang.c Subject: Re: fscanf(), fgets(), fflush() problem Message-ID: <12208@hub.ucsb.edu> Date: 25 Jun 91 00:57:48 GMT References: <1991Jun24.132920.4956@iccgcc.decnet.ab.com> Sender: news@hub.ucsb.edu Reply-To: rearl@piggy.ucsb.edu Organization: (EVIL!) Lines: 22 In-reply-to: bush@iccgcc.decnet.ab.com's message of 24 Jun 91 18:29:20 GMT In article <1991Jun24.132920.4956@iccgcc.decnet.ab.com> bush@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@piggy.ucsb.edu \ --Sisters of Mercy