In Perl, I can type:
$|++;
and anything printed to STDOUT will be automatically fflush()ed.
Is there an equivalent in C? In other words, is there some way I can tell stdio to automatically fflush stdout after every printf(), the way it automatically flushes stderr?
Try setvbuf(stdout, NULL, _IONBF, 0)
. It changes stdout
to unbuffered (_IONBF
) mode.