You can pass a character and length to a string, and it will fill a string of that length with the given character:
std::string spaces(7, ' ');
You can use the .size() std :: string property to find the length of your name; in combination with the above:
std::string name = "Michael"; std::string spaces(name.size(), ' ');
meagar
source share