PROS printf: carriage return.

I have been working with PROS on a project that it has made possible but i have run into a slight issue. This (example) line:


printf("Hello world \n");

seems to return something it should not:


Hello world
    Hello world
        Hello world
            Hello world
etc.

I am wondering if it is my incorrect use of carriage return or some other mistake that is causing this.:confused:

You are actually using a line feed or new line character ("\n") instead of a carriage return ("\r"). The short story is that you need this:


printf("Hello world\r\n");

Dating back to the era of typewriters, the line feed did just that; it literally fed a new line of paper into the typewriter. The carriage return also followed its namesake; it actually returned the carriage to the left most position, normally a duty done by physically sliding the carriage. Once the first printers appeared, the terminology carried over into computer science and C and sticks with us today.

By looking at the terminal windowโ€™s output, the system is doing exactly what it was told to do; it added a new line (went down a line) but stayed at the same horizontal position where it was and continued to print (because the virtual carriage never returned to the left). Therefore, a โ€œ\rโ€ character should first return the printing position to the left most column before advancing to the next line with โ€œ\nโ€. Does this make sense?

Yes it quite definitely does. Thank you for the quick answer.