Is it possible to modify text I printed to the terminal without clearing the screen?
For instance, if I’m showing progress of something in percentage, can I modify that percentage without having to clear the screen and printing again? I’m looking for a cross-platform way, if there is one.
Talking C++.
thanks
There are a number of ways to do this, and depending on how much effort you want to put into it, you can do a lot of cool things with ascii text in a terminal window.
Advanced: ncurses library
Easier: ansi escape characters with
printforcoutEasiest: As others have said, simply use
\rfor a carriage return without a linefeed.Edit: example of using the ESC sequence to go back two characters: