And I'll need the old DOS'ies out there probably to help remember what I'm talking about.
Let's say I'm 'cout'ing something (perhaps a percentage) that I want to update on a predated interval I have specified. It works perfectly in the code, but it updates on a new line (because i have it proceeded with endl).
My question is, if anyone remembers the old FORMAT command out there for DOS/WIN, do you remember how the text updated on the SAME LINE? There was no clear screen or anything, just text updating on the same line with the current percentage.
How is this done? I really didn't get a whole lot of luck searching around, because I did not know really how to ask this.
You need to move the cursor back to the position you want to replace and output only the characters you need to refresh.
To do this only with standard stuff you shouldn't go to a new line and then use the '\b' character for each position you need to go back.
For better solutions use Windows API or Curses
cout << " (" << setw(3) << setfill('0') << percentage << ") completed"; // use 3 characters to represent the percentage
cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; // go back to " ("
//each time you refresh
cout << setw(3) << percentage << "\b\b\b"; // display percentage using 3 characters and go back of 3 characters