I am running ubuntu with code::blocks, and am trying to create an indicator that tells me about the progress of my function:
1 2 3 4
if (last_disp != time(0)) {
last_disp = time(0);
cout << "\rRunning... (step " << t << " out of " << TIMESTEPS << ")";
}
For some reason, this does not work (displays nothing). If I replace /r with /n, it does work (proving that my use of the last_disp isn't somehow wrong). Am I doing something else wrong here?
I'm well aware of what the carriage return does... As you said, that doesn't really explain why it wasn't being displayed.. Anyway I'm just using << flush now, although I don't really understand why it's necessary...
#include <iostream>
usingnamespace std;
int main(){
int i = 10;
cout << "\rbla bla bla " << i << " bla bla" << endl;
return 0;}
/*
bla bla bla 10 bla bla
*/