I need to turn user input (a number) into an output of TAB spaces. Example I ask user:
cout << "Enter amount of spaces you would like (integer)" << endl;
cin >> n;
the (n) i need to turn it into an output like:
cout << n , endl;
and what prints on the screen would be the spaces ex input is 5 out put |_| <~~~there are five spaces there.
Sorry If I can't be clear, probably this is the reason I haven't been able to find an answer looking through other people's questions.
any help will be greatly appreciated.
Just use std::string
:
std::cout << std::string( n, ' ' );
In many cases, however, depending on what comes next, is may be
simpler to just add n
to the parameter to an std::setw
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With