运行成功的最新进度条代码

来源:互联网 发布:网络光纤传输器 编辑:程序博客网 时间:2024/06/06 13:40


源代码
#include "process.h"
#include<stdio.h>
#include<string.h>
#include<unistd.h>
void process()
{
     int i=1;
     char buf[_SIZE_];
     memset(buf, ' ', sizeof(buf));
     buf[0]='[';
     buf[101]=']';
     buf[102]='\0';
     char *lable="-\\/\0";
     for(;i<100;i++)
          {
  buf[i] = '#';
           printf("%s [%d%%][%c]\r",buf,i,lable[i%3]);
           fflush(stdout);
  sleep(1);
          }
}
int  main()
{
    process();
    return 0;
}
头文件
#ifndef __PROCESS__
#define __PROCESS__
#define _SIZE_ 103
void process();
#endif
0 0
原创粉丝点击