Quantcast
Channel: c++ Carriage Return Line Feed long string followed by a shorter string - Stack Overflow
Viewing all articles
Browse latest Browse all 2

c++ Carriage Return Line Feed long string followed by a shorter string

$
0
0

I have an application which I want to print status messages with. However, sometimes it occurs that a shorter status message follows a longer status message, which leads to the following situation:

Long message:

this is the long status message which is longer than the short one

Shorter message:

This is the short status messagewhich is longer than the short one//this one should end here      ^

The code I'm using is:

cout << StatusMessage << '\r';

How can I overcome this problem and firstly erase the whole line before printing the new line? Preferably with a cross platform solution, but for now I'm working on Windows

Note: I already tried to overwrite the line with \b or spaces, however this may result in a multiple line cleaning which removes the functionality of my \r approach.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images