Path: utzoo!utgpu!watmath!att!dptg!rutgers!iuvax!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: When to use fflush()? Keywords: fflush Message-ID: <10882@smoke.BRL.MIL> Date: 30 Aug 89 21:46:23 GMT References: <143@sherpa.uucp> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 20 In article <143@sherpa.uucp> rac@sherpa.uucp (Roger A. Cornelius) writes: >When should you use fflush()? OR are there any guarantees of >when output buffers are flushed? Use fflush() whenever you want to make sure that the buffers are forced out. >I have a program that uses fputs() to print a prompt, then waits for a >return to be typed. The prompt is always displayed, but am I guaranteed >of this? Recent versions of stdio attempt to force out all output possibly associated with a "terminal" whenever input is requested from a "terminal". It is not always possible to tell what is really a terminal, though. Modern stdio also defaults to line-buffered output on "terminals", although that wouldn't help for a prompt on the same line as the input. >Should I use fflush() anyway? What's the rule for when to use >fflush(), and when it's not needed? See my first sentence.