c++ - How to rollback lines from cout? -


I am doing a task monitoring coding, which uses the count to update the progress of the job. I would like to display one work progress per line, so I have to rollback several lines of console.

I insist on "many" because one line works for \ b , but between the lines \ n is not erased.

I tried std :: cout.seekp (std :: cout.tellp () - str.length ()); but tellp () return -1 (failure).

You can cout & lt; & Lt; '\ R'; To jump in the beginning of the current line, but to move upward is system-specific for Unix, see man termcaps and man terminfo (and Search for cursor_up ). On ANSI-compatible terminals (such as most modern terminals available on Unix), it works to proceed: cout & lt; & Lt; " [A" . Do not try to find it in

cout , this is indispensable of most of the time (except when a file is redirected).

As mentioned in other answers, the use of the ncurses (or slang ) library provides a good intuition for Terminal I / O on Unix is.


Comments