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
How about:
string s = " "; // 10 spaces string n = "123"; n.length() <= 10 ? s.replace(10 - n.length(), n.length(), s) : s = n;