Skip to content

Instantly share code, notes, and snippets.

@ryankurte
Created June 28, 2015 21:21
Show Gist options
  • Save ryankurte/bc3a47e43cbddd2323f5 to your computer and use it in GitHub Desktop.
Save ryankurte/bc3a47e43cbddd2323f5 to your computer and use it in GitHub Desktop.
C Command Line Progress Bar
void print_progress(unsigned int bar_size, float progress)
{
printf("[");
int8_t pos = bar_size * progress;
for (int i = 0; i < bar_size; ++i) {
if (i < pos) {
PRINTF("=");
} else if (i == pos) {
PRINTF(">");
} else {
PRINTF(" ");
}
}
printf("] %d %%\r", (int)(progress * 100));
fflush(stdout);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment