This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc
- From: Segher Boessenkool <segher at koffie dot nl>
- To: Matthieu Moy <Matthieu dot Moy at imag dot fr>
- Cc: Stuart Longland <stuartl at longlandclan dot hopto dot org>,Arash Farmand <arashfarmand at hotmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Tue, 01 Apr 2003 21:59:37 +0200
- Subject: Re: gcc
- References: <F63suZ2K4xDh9vXsFFs0000dc50@hotmail.com> <vpqadfcuhnn.fsf@imag.fr> <3E87EE8F.4070104@longlandclan.hopto.org> <vpqu1dkt0s9.fsf@imag.fr>
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