淘客推广渠道,seo项目优化案例分析文档,端午节网页设计模板,餐饮网站建设案例一、简单介绍make/Makefile Makefile 和 makefile 不区分大小写#xff0c;但是一定只能是 “makefile” #xff01;#xff01;#xff01; make 是一个指令#xff0c;makefile 是一个文件。
Makefile 格式形式#xff1a; 使用 make 生成目标文件时#xff0c;默认…一、简单介绍make/Makefile Makefile 和 makefile 不区分大小写但是一定只能是 “makefile” make 是一个指令makefile 是一个文件。
Makefile 格式形式 使用 make 生成目标文件时默认从上到下扫描 Makefile 文件默认形成的是第一个目标文件——默认只生成一个。 二、进度条的设计与实现
进度条应与实际的业务结合单独存在没有意义。因此下面模拟了一个下载场景结合下载场景完成进度条的设计。
【Makefile 文件】
processbar:test.o processbar.ogcc -o $ $^
test.o:test.cgcc -c test.c
processbar.o:processbar.cgcc -c processbar.c.PHONY:clean
clean:rm -f processbar test.o processbar.o 【processbar.h】 1 #include stdio.h2 #include string.h3 #include unistd.h4 #include stdlib.h5 #include time.h6 7 8 #define MAX 1039 10 #define Head 11 #define Body 12 13 void process_fflush(double rate); 【processbar.c】 1 #include processbar.h2 3 4 char* spit -\\|/;5 6 char buff[MAX] {0}; 7 void process_fflush(double rate)8 { 9 static int cnt 0; 10 int n strlen(spit); 11 if (rate 0.5) buff[0] Head;12 13 printf([%-100s][%.1f%%][%c]\r, buff, rate, spit[cnt%n]);14 fflush(stdout); 15 buff[(int)rate] Body; 16 if ((int)rate 99) buff[(int)rate 1] Head;17 18 cnt;19 20 if (rate 100.0) printf(\n);21 }【test.c】 1 #include processbar.h2 3 #define FILE_SIZE 1024*1024*10244 5 void download()6 {7 int total FILE_SIZE;8 srand(time(NULL)^1023);9 while (total)10 {11 usleep(20000);12 int one rand()%(2 * 1024 * 1024);13 total - one;14 if (total 0)15 total 0;16 17 int download FILE_SIZE - total;18 double rate (download * 1.0 / (FILE_SIZE)) *100;19 process_fflush(rate);20 }21 }22 23 int main()24 {25 download();26 return 0;27 }