#include <stdio.h>
#include <windows.h>
#include <boost/progress.hpp>
int main(int argc, char **argv) {
boost::progress_display pd(100);
for (int i = 0; i < 100; i++) {
Sleep(rand() % 300);
++pd;
}
return 0;
}
运行效果:
说明:
- 声明对象的时候,需要带入进度显示基数,就比如文件下载,文件大小就是这个基数
- ++pd是支持的,pd++不支持,也可以用pd+=n
- 输出进度的同时,尽量不要在输出其他内容,避免输出内容混乱,比如: