I want to insert 'n' spaces (or any string) at the beginning of a string in C++. Is there any direct way to do this using either std::strings or char* strings?
E.g. in Python you could simply do
>>> "." * 5 + "lolcat"
'.....lolcat'
In the particular case of repeating a single character, you can use std::string(size_type count, CharT ch)
:
std::string(5, '.') + "lolcat"
NB. This can't be used to repeat multi-character strings.