源代码:
#include <stdio.h>
2 #include <unistd.h>
3 int main()
4 {
5 int i=0;
6 char bar[102];
7 const char* lable="\/-/\";
8 bar[0]=0;
9 while(i<=100)
10 {
11 printf("[%-100s]%d%%[%c]\r",bar,i,lable[i%4]);
12 bar[i]='=';
13 fflush(stdout);
14 i++;
15 bar[i]=0;
16 usleep(1000000);
17 }
18 printf("\n");
19 return 0;
20 }
效果展示: