

Ask HN: When did fflush got defined for stdin as well? - irahul

Today I checked the man for fflush and this surprised me:<p><pre><code>       For output streams, fflush() forces a write of all user-space buffered data for the given output or update stream via the stream's underly
       ing write function.  For input streams, fflush() discards any buffered data that has been fetched from the underlying  file,  but  has  not
       been by the application.  The open status of the stream is unaffected.

</code></pre>
I remember it very clearly fflush was defined only for output streams.<p>I looked at my copy of K&#38;R and K&#38;R defines it as such:<p>int fflush(FILE *stream)
On an output stream, fflush causes any buffered but unwritten data to be written; on
an input stream, the effect is undefined. It returns EOF for a write error, and zero
otherwise. fflush(NULL) flushes all output streams.<p>When did the change happen?
======
burgerbrain
Read further down in your manpage:

    
    
      CONFORMING TO
           C89, C99, POSIX.1-2001, POSIX.1-2008.
    
           The standards do not specify the behavior for input streams.  Most other implementations behave the same as Linux.

~~~
irahul
Oh, thanks. The earlier version of the man page had output stream in the
description(if my memory isn't failing me).

I searched for fflush C99 and based on absence of any credible link, I assumed
nothing has changed in C99(and nothing really has changed as far as standards
go).

