源代码
#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