【Linux】make 和 makefile
进度条
#pragma once
#include <stdio.h>
#define NUM 102
#define BODY '='
#define TOP 100
#define RIGHT '>'
extern void processbar(int rate);
#include "processBar.h"
#include <string.h>
#include <unistd.h>
const char lable[] = "|/-\\";
char bar[NUM] = {0};
void processbar(int rate)
{
if(rate < 0 || rate > 100)
{
return;
}
int len = strlen(lable);
printf("[%-100s][%d%%][%c]\r",bar,rate,lable[rate%len]);
fflush(stdout);
bar[rate++] = BODY;
if(rate < TOP)
{
bar[rate] = RIGHT;
}
}
#include "processBar.h"
#include <unistd.h>
int main()
{
int total = 10000;
int curr = 0;
while(curr <= total)
{
processbar(curr * 100 / total);
//任务开始
curr += 10;
usleep(3000);
}
printf("\n");
return 0;
}
process: processBar.o main.o
@gcc -o $@ $^
@rm -rf processBar.o main.o
processBar.o: processBar.c
@gcc -c $^ -o $@
main.o: main.c
@gcc -c $^ -o $@
.PHONY:clean
clean:
@rm -rf process
原文地址:https://blog.csdn.net/FZC206/article/details/138042428
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!