> Can anybody remind me of the format command, or otherwise, to print a
number
of the same character e.g. if I wanted to printout 20 *'s
********************
There are quite a few possibilities. One reasonably clean one would be:
std::fill_n(std::ostream_iterator<char>(std::cout) , 20, '*');
If you prefer to use only the native abilities of iostreams, you could
use:
std::cout << std::setfill('*') << std::setw(20) << ' ';
but this prints an extra space at the end of the line -- if that's all
that's going to go on the line, you might prefer:
std::cout << std::setfill('*') << std::setw(20) << '\n';
or, if you don't want a new line, something like:
std::cout << std::setfill('*') << std::setw(19) << '*';
At least in theory, the versions using iostreams capabilities might be
marginally more efficient, but given that this is producing output on a
stream, it's hard to imagine how it would make any real difference, so
at least to me, fill_n seems the obvious choice.
--
Later,
Jerry.
The universe is a figment of its own imagination.