我想輸出一個整數爲std::stringstream
等效格式爲printf
的%02d
。是否有更簡單的方法來實現這一目標比:等同於%02d與std :: stringstream?
std::stringstream stream;
stream.setfill('0');
stream.setw(2);
stream << value;
是否有可能流某種格式標誌的stringstream
,像(僞):
stream << flags("%02d") << value;
不應該是'stream.fill('0')'和'stream.width(2)'?你正在使用操縱器的名字,就像你知道自己問題的答案一樣? – 2010-05-15 09:34:31