Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Progress bar
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> #include <iomanip> #include <sstream> #include <string> #include <chrono> #include <thread> std::string buildProgressdBar(const int percent) { std::stringstream ss; ss << "Progress: " << std::setw(3) << percent << "% ["; for(int i=0; i<100; i+=2) { if(i<=percent) ss << '#'; else ss << '-'; } ss<<']'; return ss.str(); } void showProgressBar(const int percent) { std::string bar = buildProgressdBar(percent); const std::string backspace(bar.size(),'\b'); std::cout << backspace << bar << std::flush; } int main() { const int COUNT = 200; for(int i=0; i<COUNT; i++) { showProgressBar(i*100.0/COUNT); // Job emulating: std::this_thread::sleep_for(std::chrono::milliseconds(3000/COUNT)); } showProgressBar(100); std::cout<<"\n\nPress [Enter] to continue..."<<std::endl; std::cin.ignore(1); return 0; }
run
|
edit
|
history
|
help
0
Workaround for https://github.com/Project-OSRM/osrm-backend/pull/4385
Test
MSVC C++ runtime bug in dynamic_cast
rstring
hangman
Cannot allocate an array of constant size 0
Attribute of qi parsers
-1 Girene Kadar Ortalama
zero size std::array parameter
IBE FT ParseFileName