I\'m writing a console program in C++ to download a large file. I have known the file size, and I start a work thread to download. I want to show a progress indicator to mak
You can use a "carriage return" (\r) without a line-feed (\n), and hope your console does the right thing.
Another way could be showing the "Dots" or any character you want .The below code will print progress indicator [sort of loading...]as dots every after 1 sec.
PS : I am using sleep here. Think twice if performance is concern.
#include<iostream>
using namespace std;
int main()
{
int count = 0;
cout << "Will load in 10 Sec " << endl << "Loading ";
for(count;count < 10; ++count){
cout << ". " ;
fflush(stdout);
sleep(1);
}
cout << endl << "Done" <<endl;
return 0;
}