C標準ライブラリ関数fflushにヌルポインタを指定すると、プログラムが現在開いている全てのストリームをフラッシュする。
fflush(NULL); // OK
C99 7.19.5.2/p1-3より引用(下線部は強調)。
#include <stdio.h> int fflush(FILE *stream);2 If
streampoints to an output stream or an update stream in which the most recent operation was not input, thefflushfunction causes anyunwritten data for that stream to be delivered to the host environment to be written to the file; otherwise, the behavior is undefined.
3 Ifstreamis a null pointer, thefflushfunction performs this flushing action on all streams for which the behavior is defined above.
(PDF) C99 Rationale, 7.19.5.2より引用。
The
fflushfunction ensures that output has been forced out of internal I/O buffers for a specified stream. Occasionally, however, it is necessary to ensure that all output is forced out, and the programmer may not conveniently be able to specify all the currently open streams, perhaps because some streams are manipulated within library packages. To provide an implementation-independent method of flushing all output buffers, the Standard specifies that this is the result of callingfflushwith aNULLargument.
関連URL