This is from the unix man page, but should be relevant...
Also, cerr is not buffered, just a note...
Standard I/O Functions fflush(3S)
NAME
fflush - flush a stream
SYNOPSIS
#include <stdio.h>
int fflush(FILE *stream);
DESCRIPTION
If stream points to an output stream or an update stream in
which the most recent operation was not input, fflush()
causes any unwritten data for that stream to be written to
the file, and the st_ctime and st_mtime fields of the under-
lying file are marked for update.
If stream is a null pointer, fflush() performs this flushing
Disclaimer:
Beware: Studies have shown that research causes cancer in lab rats.