Created
November 11, 2015 18:40
-
-
Save phrz/a42907ec371a987bb5fb to your computer and use it in GitHub Desktop.
I made a command line progress bar in C++ for funsies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
int width = 15; | |
for(int p = 0; p <= 100; ++p) { | |
int full = (double)p/100*width; | |
cout << string(100,'\n'); | |
cout << setw(3) << p; | |
cout << "% ["; | |
for(int i = 0; i < full; ++i) cout << "█"; | |
cout << string(width-full, ' '); | |
cout << "]" << string(8,'\n'); | |
cout.flush(); | |
usleep(500*1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment