On 28 Apr 2002 12:15:52 +0300, Oleg Goldshmidt <[EMAIL PROTECTED]> wrote:
> 
> I'd say, as a rule of thumb, that fflush(3) is a very blunt tool and
> should not be used lightly. This is especially true about
> fflush(NULL). If you want to change the default
> buffering settingsit is cleaner to use setbuf(3) and friends
> consistently rather than call fflush(3) at odd places.

The fflush is there for a reason. When you have file opened in I/O
mode (e.g. a terminal) and you want to write lines without LF, you
must use fflush before reading.
Making the file TOTALLY unbuffered (_IONBF) is not guaranteed to
show all the output before the user types her answer.

Another occasion that I had to use fflush was a case of transparent
printing to a terminal (all the characters between "mc4" and "mc5" are
sent to the slave printer. See prtr_on / prtr_off in man terminfo).
This was complicated by the fact that beside printing the terminal was
in use in interactive mode at the SAME time.
In this case the printing buffer was defined as fully buffer (_IOFBF)
with buffer size that was greater than any block sent to the printer.
After the buffer was filled (by fputc/fputf/fwrite) it was flushed.
This ensured that the whole block was written in one chunk to the
terminal (it worked even when the terminal was connected serially).

Ehud.


-- 
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 mailto:[EMAIL PROTECTED]          Better  Safe  Than  Sorry

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to