fork(119) download
  1. #include <iostream>
  2.  
  3. int main() {
  4. float progress = 0.0;
  5. while (progress < 1.0) {
  6. int barWidth = 70;
  7.  
  8. std::cout << "[";
  9. int pos = barWidth * progress;
  10. for (int i = 0; i < barWidth; ++i) {
  11. if (i < pos) std::cout << "=";
  12. else if (i == pos) std::cout << ">";
  13. else std::cout << " ";
  14. }
  15. std::cout << "] " << int(progress * 100.0) << " %\r";
  16. std::cout.flush();
  17.  
  18. progress += 0.16; // for demonstration only
  19. }
  20. std::cout << std::endl;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
[>                                                                     ] 0 %
[===========>                                                          ] 15 %
[======================>                                               ] 31 %
[=================================>                                    ] 47 %
[============================================>                         ] 63 %
[========================================================>             ] 80 %
[===================================================================>  ] 96 %