What does fflush() do?

Hi all,

I program in C/C++ a bit but am never really sure what fflush() actually does. I've read the Linux manual for the this function, and it says "For output streams, fflush() forces a write of all user-space buffered data for the given output or update stream via the stream's underlying write function..."

Here, I'm particularly interested in fflush(stdout) since I just saw a program with "printf(...)" followed immediately by "fflush(stdout)". Does this mean that the printf can possibly fail to write all data to the screen but leave some in its buffer. If so, what's a situation in which printf leaves some data in the buffer without writing them to the standard output?

Can someone enlighten me?

Thanks very much in advance.
Topic archived. No new replies allowed.