I have string example = "something"
How to add to this variable example 10 blank spaces?
This would be result example = "something "
Your example doesn't seem to match your description. Surely, if you're adding 10 blank spaces it would be "something ".
Nevertheless, the
append()
of the C++ string class adds values to the end of a string.
EDIT: Thought I'd best add an example...
1 2 3
|
string example = "something";
example.append( 10, " " );
|
Double edit: Ha, I didn't realise that the formatting on this forum would bin off the trailing spaces. My apologies.
Last edited on
I write wrong. This would be result example = "something [10] blank spaces behind]"
Both iHutch and myself gave an answer that would produce what you've asked for. It would turn this:
"something"
into
Last edited on