[Solved] Newlines and logging output with printf ...
Posted: Thu Oct 13, 2016 12:44 am
In an attempt to debug some code, I was getting the strangest results in my console output after switching on some debug in a 3rd party library. I couldn't for the life of me figure out what was going on. About an hour later I had a theory and said "No ... that can't be right!" ... so I ran a test. I compiled a C program that contained:
when run, what would you expect the result to be. What I was expecting was:
what I found was:
oh my!!! ... it seems we are loosing the content (silently) after the first newline in output.
Is this expected behavior?
Code: Select all
printf("This is line1\nThis is line2\n");
Code: Select all
... stuff before ...
This is line1
This is line2
... stuff after ...
Code: Select all
... stuff before ...
This is line 1
... stuff after ...
Is this expected behavior?