"Nadav Har'El" <[EMAIL PROTECTED]> writes:

> > As a test u can also try fflush(NULL); which flushes
> > all the opened streems.
> 
> Right, but as far as I know this is not a standard thing. As well as
> doing a rather stupid thing to do, because you usually know which
> stream you should flush, and doing fflush(NULL) might flush
> something you didn't want to (e.g., imagine some library opening a
> file you aren't aware of).

The same fflush(3) man page on Linux says

       If the stream argument is NULL, fflush  flushes  all  open
       output streams.

NB: output streams only.

Further down the man page:

CONFORMING TO
       The fflush function conforms to ANSI  X3.159-1989  (``ANSI
       C'').

FWIW, there is also

NOTES
       Note  that fflush only flushes the user space buffers pro­
       vided by the C library.  To ensure that the data is physi­
       cally  stored  on  disk the kernel buffers must be flushed
       too, e.g. with sync(2) or fsync(2).

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.

-- 
Oleg Goldshmidt | [EMAIL PROTECTED] 
"We work by wit, and not by witchcraft,
 And wit depends on dilatory time..."

================================================================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