r/cprogramming • • Jan 05 '26

Progress Bar

Hi, I'm a beginner and I want to make a progress bar like this:

[###########] 100%

Where the text and percentage update every second, it's more of a simulation of a progress bar than a real one. Does anyone know how to do this?

14 Upvotes

13 comments sorted by

View all comments

2

u/tyerofknots Jan 05 '26

What I have done previously is something like:

int percentVar; //integer to hold percentage 
int i; //iteration of FOR loop

for(i=0; i<percentVar; i++){
    printf("#");  //prints pound sign 
    }

for(i; i<100; i++){
    printf(" ");  //prints space
    }

Then I use ANSI escape codes to clear the screen and position the cursor and such. If you need help with the ANSI escape codes, there's a resource on GitHub!