If you add a '
'
to your message it will (or should), ie. "hello-out
"
.
The reason being is that stdout
is buffered in order to be more efficient, whereas stderr
doesn't buffer it's output and is more appropriate for error messages and things that need to be printed immediately.
stdout
will usually be flushed when:
- A newline (
) is to be printed
- You read in from
stdin
fflush()
is called on it
EDIT: The other thing I wanted to add before my computer crashed...twice...was that you can also use setbuf(stdout, NULL);
to disable buffering of stdout
. I've done that before when I've had to use write()
(Unix) and didn't want my output to be buffered.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…