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++?
Sample input:
123
I was looking the topic because Im developing VCL; Anyway making a function wasn't not so hard.
void addWhiteSpcs(string &str, int maxLength) {
int i, length;
length = str.length();
for(i=length; i
In both cases it will add to the right 10 blank spaces. I Recomend to use monospace fonts like courier or consolas for a correct format.
This is what happens when you're not using monospace font
johnny____
cash______
// using monospace font the output will be
johnny____
cash______
Both cases have the same length.