Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 464 Bytes

Progess-Bar.md

File metadata and controls

17 lines (15 loc) · 464 Bytes
void printProgressBar(int current, int total) {
	int width = 50; // Width of the progress bar
    float progress = (float)current / total;
    int pos = width * progress;

    printf("\r[");
    for (int i = 0; i < width; ++i) {
        if (i < pos) printf("=");
        else if (i == pos) printf(">");
        else printf(" ");
    }
    printf("] %d%% (%d/%d)", (int)(progress * 100.0), current, total);
    fflush(stdout); // Flush the output buffer
}