【c++】输出 0000,0001,0002,0003,0004...这样的字符串

#include <iostream>
#include <iomanip>
int frameCount = 0;
while(1){
            stringstream buf;
            buf <<setfill('0') << setw(4)<< frameCount;
            string num = buf.str();
            frameCount++;

}


for(int i=0; i < 15; i++)
{
    cout << setfill('0') << setw(4) << i << endl;
}


参考 http://stackoverflow.com/questions/2999016/print-numbers-sequentially-using-printf-with-filling-zeroes

posted @ 2015-06-14 20:23  小菜鸟_yang  阅读(1310)  评论(0编辑  收藏  举报