progress_display能夠在控制檯顯示程序的執行進度,若是程序執行很耗費時間,那麼它可以提供一個友好的用戶界面ios
#include <boost\timer.hpp> #include <boost\progress.hpp> #include <boost\progress.hpp> #include <vector> #include <fstream> #include <boost\static_assert.hpp> #include <iostream> using namespace boost; using namespace std; int main() { vector<string> v(10000); //一個字符串向量 for(int i=0;i<10000;i++) //初始化字符串向量 v[i]="a"; ofstream fs("c:\\test.txt"); //文件輸出 流 progress_display pd(v.size()); //聲明一個progress_display對象,基數是v的大小 vector<string>::iterator pos; //迭代器 //開始寫入文件 for(pos=v.begin();pos!=v.end();++pos) { fs<<*pos<<endl; ++pd; } }