I\'m using std::string and need to left pad them to a given width. What is the recommended way to do this in C++?
std::string
Sample input:
123
The easiest way I can think of would be with a stringstream:
string foo = "foo"; stringstream ss; ss << setw(10) << foo; foo = ss.str();
foo should now be padded.
foo