I'm trying to make a progressbar for my program that's running on a unix server. It's at the end of a large for loop and looks like this:
struct CodeBook{
string Residue;
vector<string> CodeWords;
};
int r = 0, d = 2;
string code;
vector<CodeBook> CodeBooks(Weight(n+1, 4, d));
for (r = 0; r < Weight(n+1, 4, d); r++){
do{
getline(Input, code);
if (code[0] == 'R') CodeBooks[r].Residue = code;
else if (isdigit(code[0]))CodeBooks[r].CodeWords.push_back(code);
} while (code != ""); //if the line is empty, end the loop and move to the next
if (r%256==0) {fflush(stdout); cout << (r / Weight(n+1, 4, d)) << "\r";} //the problem
}
All it does is print a never-changing 0 at the beginning of the line with the cursor over it. What am I doing wrong?