I want to output an integer to a std::stringstream
with the equivalent format of printf
's %02d
. Is there an easier way to achieve this than:
std::stringstream stream;
stream.setfill('0');
stream.setw(2);
stream << value;
Is it possible to stream some sort of format flags to the stringstream
, something like (pseudocode):
stream << flags("%02d") << value;
See Question&Answers more detail:os