推荐阅读fflush有什么作用
引文来自MSDN
Fflush has no effect on an unbuffered stream. Buffers are normally maintained by the operating system, which determines the optimal time to write the data automatically to disk: when a buffer is full, when a stream is closed, or when a program terminates normally without closing the stream.
大意是:
Fflush函数对未缓冲的流没有影响。缓冲区通常是由操作系统维护的,这决定了自动写数据到硬盘的最佳时间:当缓冲区已满,当一个流被关闭,或当程序正常终止没有关闭流。