Last active
March 21, 2023 12:53
-
-
Save sgkim126/c5699b1b1094478d6f3bb8d297401b63 to your computer and use it in GitHub Desktop.
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
void display_progress_bar(int progress) { | |
static const int PROGRESS_BAR_LENGTH = 20; | |
int filled = progress * PROGRESS_BAR_LENGTH / 100; | |
fprintf(stderr, "\r["); | |
for (int i = 0; i < filled; i += 1) { | |
fprintf(stderr, "#"); | |
} | |
for (int i = filled; i < PROGRESS_BAR_LENGTH; i += 1) { | |
fprintf(stderr, " "); | |
} | |
fprintf(stderr, "] %3d% %", progress); | |
if (filled == PROGRESS_BAR_LENGTH) { | |
fprintf(stderr, "\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment