void doProgress(char* label, size_t step, size_t total) { //progress width const int pwidth = 60; //minus label len size_t width = pwidth - strlen(label); size_t pos = (step * width) / total; size_t percent = (step * 100) / total; printf("\r%s%4d/%4d [", label, step, total); int i; //fill progress bar with = for (i = 0; i < pos; i++) { printf("%c", '='); } //fill progress bar with spaces printf("% *c", width - pos + 1, ']'); printf("%3d%%", percent); fflush(stdout); }