How to write 'n' copies of a character to ostream like in python
The obvious way would be with fill_n
:
std::fill_n(std::ostream_iterator<char>(std::cout), 5, 'a');
Another possibility would be be to just construct a string:
std::cout << std::string(5, 'a');
Use some tricky way:
os << setw(n) << setfill(c) << "";
Where n is number of char c to write