Making a program that has a % progress bar of sorts, its really spammy though. It's creating 100,000 numbers, and showing how far along in the progress it actually is, with a 1% 2% 3% kind of feel, only problem is, it's making the console flood with those numbers, about a thousand of them per percentage increase.
It's probably irrelevant but heres the code I'm using
int testing() {
cout << "Open file\n";
fstream outFile("text.txt", ios::out);
int number = 100000;
for (int i = 1; i != number + 1; i++) {
outFile << i << endl;
cout << (i / 1000) << endl;
//cout << clearLastLine();
}
outFile.close();
cout << "File Closed\n";
return 0;
}
The commented cout is what I want to use (it doesn't exist to my knowledge). Every time the cout << i/1000 << endl;
triggers, I want it to remove that number it just put into the console window, so it can be replaced with the next number. Is this possible? If it is, I'd love to know - thanks. -- This picture below, shows why I want it to clear the last line that was outputted.
New code that makes it less spammy, but I still end up with 100 lines of console I do not want, however I still want the newest number to display, just the others not to.
int testing() {
cout << "Open file\n";
fstream outFile("text.txt", ios::out);
int number = 100000;
int percentifier = number * .01; // added this so I can change number to be anything I want
int temp2 = 0;
for (int i = 1; i != number + 1; i++) {
outFile << i << endl;
int temp = i / percentifier;
if (temp != temp2) {
//cout << clearLastLine();
cout << (temp) << "%" << endl;
}
temp2 = i / percentifier;
}
outFile.close();
cout << "File Closed\n";
return 0;
}