Possible Duplicate:
How to update a printed message in terminal without reprinting (Linux)
I have c++ code, performing some simulations.
I want to show the percentage of my simulation, but I don’t want to output a new line every step, like
%1
%2
%3
…
Is there a way, in c++ or in shell scripts to show the progress without creating new lines?
Thanks
Edit 1
Anyone know how to update a number on my personal webpage without refreshing the whole page?
Thanks
Edit 2
double N=0;
forAll (internalIDs_, i) {
N++;
double percent = 100*N/internalIDs_.size();
// Info<< "\rProgress: " << percent << "%" << endl;
printf("\r[%6.4f%%]",percent);}
The terminal cursor keeps blinking cyclically through the numbers, very annoything, how to get rid of this?
The trick used for this is to return to the first position in the current line instead of progressing to the next line.
This is done by writing the
\rcharacter (carriage return) to the terminal/stdout.