gcc

Segher Boessenkool segher@koffie.nl
Wed Apr 2 00:42:00 GMT 2003


Matthieu Moy wrote:
> If the program ends properly, I  think the output *has* to be flushed,

Yes.  If main() returns or exit() is called, all open streams are
closed; if an open stream is closed, it is flushed.

> That's why its generally  a good advice to put "\n" at  the end of any
> debug/test output. 

Note that (on typical Unix-like systems) only stderr is line buffered
by default; stdout is block buffered.  This means that a '\n' char
is not enough to flush stdout; either explicitly call fflush() or
use setbuf() or setvbuf().


Segher




More information about the Gcc-help mailing list