Buffered I/O issues (stdout, stdin)

Matthew Iselin matthew@theiselins.net
Tue Feb 26 10:44:00 GMT 2008

Hi everyone,

I'm having some trouble with a port of Newlib 1.15.0 to my operating
system in the printf function. It seems that the streams are all using
buffered I/O and if the last string printed does not have a newline it
simply is not printed at all.

I also notice strange behavior with this sort of code:

printf( "testing 123: %s\n", "hello\nworld" );

The output will be "testing 123: hello\n", which doesn't seem to be
correct. The write system call is only called for the characters
actually printed, not for the ones after, and including, the newline
(ie, "\nworld").

There's also a problem with getchar, which requires me to hit enter
before it actually returns (could this be a side effect of the read
system call - what is the standard behavior when dealing with newlines
and the like within my console I/O functions?).

Some help on this would be greatly appreciated. Thanks in advance.

More information about the Newlib mailing list