首先编写进度条程序
#include<stdio.h>
#include<unistd.h>
int main(main)
{
int i=0;
char buf[102]="#";
char sym[]="|/-\\";
for(i=1;i<=100;i++)
{
buf[i]='#';
printf("\033[42m[%-100s]\033[0m[%d%%][%c]\r",buf,i,sym[i%4]);
fflush(stdout);
usleep(100000);
}
printf("\n");
}
然后编写一个Makefile
test:test.c
gcc -g $^ -o $@
.PHONY:clean
clean:
rm test
保存退出后
在命令行输入make
最后输入/.test运行该程序