模拟下载进度条

#include <stdio.h>#include <unistd.h>
int main (){
        int i,j;
        for (j=0;j<23;j++){
                printf("n");
        }
        printf("[   >tttttttt   ]");
        for (j=0;j<64;j++)
                printf("b");
        for (i=0;i<61;i++){
                printf("b");
                for (j=i;j<i+1;j++)
                        printf("=");
                printf(">");
                for (j=0;j<64-i;j++)
                        printf(" ");
                printf("] %d%",i);
                for (j=0;j<67-i;j++)
                        printf("b");
                for (j=i;j/10!=0;j=j/10)
                        printf("b");
                fflush(stdout);
                sleep (1);
        }
        printf("n");
        return 0;
}

存在问题:1、对不同大小终端识别2、加快更新频率3、输出百分比

4 thoughts on “模拟下载进度条

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.