[Ilugc] Progressbar on shell

Arun Venkataswamy arun289 at gmail.com
Thu Dec 25 17:01:48 IST 2008


On Thu, Dec 25, 2008 at 2:50 PM, abdullah abdul Khadir <
abdullah.ak2002 at gmail.com> wrote:

> Hi,
>      Does anyone here know how to implement a progress bar in C that
> displays a series of '=' on the command line when run. I intend the
> progressbar to look like :
>
> |=========>
> |   [25%]
>
>
Simple C code - without any data validation

void pbar(int width,int percent)
{
int a;
    printf("\r[");
    for(a=0;a<(percent*width/100);a++) printf("=");
    printf(">");
    for(;a<width;a++) printf(" ");
    printf("]%d%%",percent);
}

Displays the number also on the same line but....

-- 

Arun Venkataswamy


More information about the ilugc mailing list