I need to create a string of blanks in c++, where the number of spaces is a variable, so I can't just type it in. How do I do this without looping ?
Thanks!
I need to create a string of blanks in c++, where the number of spaces is a variable, so I can't just type it in. How do I do this without looping ?
Thanks!
std::string blanks = " ";
Or perhaps more useful to you:
size_t size = 5; // size_t is similar to unsigned int ‡
std::string blanks(size, ' ');
See: http://www.cplusplus.com/reference/string/string/string/
‡ See the question on size_t if this isn't clear.
#include <string>
.....
//i is your variable length
string s_blanks_length_i( i, ' ' );