I have 3 different processes that all print out single characters using
printf. But I can't see them in the terminal. When I add a newline,
printf("\n H") so each character is on a new line, I can see them. Why doesn't it work without the newline character?
Its a matter of flushing. If you flush the buffers after each
printf, you should get output closer to what you want. To flush the standard output simply do
fflush( stdout ).
The C standard defines 3 types of buffering for output streams:
<li>Unbuffered → no buffering done</li>
<li>Line-buffered → buffer until newline seen</li>
<li>Fully-bufferd → buffer up to the buffer size</li>
An output stream's buffering type can be changed via the
The C standard requires
stderr to not be fully-buffered at startup (it is usually unbuffered on many implementations, so as to see errors as soon as posible); and
stdout to be fully-buffered only if it can be determined to not refer to a terminal (when it refers to a terminal, many implementations initialize it as line-buffered, which is what you are seeing).
use'write(1,&c,1)' system call, or