How to overwrite in a console Application
-
Hey guys, I have a little problem which is I’m updating my output every 50 ms but I don't want the output to display several times, but just want to directly rectify the given display.
-
@Zac-Boussaid said in How to overwrite in a console Application:
but I don't want the output to display several times
What do you mean?
Please explain better what exactly you want and what you get. -
Hi
There is little console/cursor control in plain c++.You could use ncurses or Termbox or anything similar.
-
Hi,
The most robust way to do what you want would be to use the ncurses library.
Otherwise, this stack overflow answer looks pretty good (not tested myself, but the logic looks correct).
-
@jsulm i would like to have something similar to this picture:
The output is displayed once this is because i'm calling my function just one time. now if i want to call the same function several of time to update the output but without displaying that more than one time
see Picture bellow -
@Zac-Boussaid
The simple answer is I don't think you can do this. @SGaist's stackoverflow post does what I thought of, which is emit\r
carriage-returns to move the cursor back to the start of a line to overwrite. But that would only work for one line, and what you want is to "back up" 8 lines each time, and I don't know of any way to do that. Other than @SGaist's suggestion ofncurses
, which is a whole different ball-game.