Linux下C语言进度条

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/better12038/article/details/83899934
    #include <stdio.h>                                                                                                                   
  2 #include <unistd.h>                                                                                                                     
  3                                                                                                                                         
  4 int main()                                                                                                                              
  5 {                                                                                                                                       
  6   char split[4] = {'-','/','|','\\'};                                                                                                   
  7   char buf[1024] = {0};                                                                                                                 
  8   int i = 0;                                                                                                                            
  9   for(; i<100; ++i){                                                                                                                    
 10      buf[i] = '#';                                                                                                                      
 11      printf("[%d%%][%c][%s]\r",i,split[i % 4],buf);                                                                                     
 12                                                                                                                                         
 13      fflush(stdout);                                                                                                                    
 14      usleep(200*1000);                                                                                                                  
 15   }                                                                                                                                     
 16   return 0;                                                                                                                             
 17                                                                                                                                         
 18 }                

猜你喜欢

转载自blog.csdn.net/better12038/article/details/83899934