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
5sdgts
get_number_of_threads, windows
MSVCStatic
SFINAE with std::enable_if
hex manip
vector destruction - visual studio
hangman
empty base bug
define_xml_tags
multiplie linked list numbers