Sunday, February 1, 2015

Progress indicator in C

#include <stdio.h>
int  main(void) {
int i;
char *t="%";
char *p="progress: ";
for(i=0;i<=200000;i++) {
        printf("\e[?25l"); /* hide the cursor */
        printf("%s %d %s",p,i/2000,t);
        printf("\r");
                }
        printf("\e[?25h"); /* show the cursor */
}


No comments: