printf() woes

Matthew Woehlke
Wed Jan 30 22:15:00 GMT 2008

Rick Mann wrote:
> Hi. I'm using newlib 1.14 on an Atmel ARM processor, and printf() is 
> behaving strangely.
> The following code
>     printf("1. Hello worldCRLF1\r\n");
>     printf("2. Hello worldCRLF\r\n");
>     printf("3. Hello worldCRLF\r\nHello worldCRLF\r\n");
>     printf("4. Hello worldLF\nHello worldLF\n");
>     printf("5. Hello worldNULL");
>     printf("6. Hello worldLF\n");
> prints:
> 3. Hello worldCRLF1
> 4. Hello worldLF
>                 Hello worldLF6. Hello worldLF
> Using snprintf() works just fine.
> Newlib's printf() is doing something with newlines, and printf() calls 
> without newline, and not handling it the way I really want. Perhaps it's 
> a configuration things somewhere, but I don't really know where to look.
> Any suggestions?

Have you looked at the output piped through 'od' (or redirected to a 
file, and examined in either vim or a hex viewer/editor)? It sure looks 
like line 1 printed, line 2 printed over top of it, and line 3 printed 
over top of that... but then I'm not sure what happened. Anyway, the 
point is it may be that printf works just fine, but your terminal is 
doing something funny/unexpected displaying the resulting bytes.

No animal should ever jump on the dining room furniture unless 
absolutely certain he can hold his own in conversation -- Fran Lebowitz

More information about the Newlib mailing list