Forum Discussion
Altera_Forum
Honored Contributor
21 years agoprintf("Hello World \n\r")
To get nios2 to print a line and start a new at left boarder I find it necessary to do printf(" Hello world \n\r"); \n alone only advances the line. \r gives the carriage return. In the ...
Altera_Forum
Honored Contributor
21 years ago\n means different things depending on the OS. In linux you don't get the carriage return when you use \n so if you don't have that then you'll end up on a new line but spaced over to where the last line stopped. So the \r makes it return to the beginning of the line and \n does the actual line feed (think of a typewritter where you turn the knob and pull the lever to start the next line).
And if I got everything completely backwards I'm sorry (I haven't program much in linux I just remember this being a formatting issue I ran into a while back). The reason why the hello world program probably didn't have them was it was probably intended to be received on a Windows machine, if you try to receive the data in Cygwin or any other linux type system then you will not get the data formatted properly depending on the system used. Cheers