The first thing that comes to my mind is to do a bunch of 's, but that would cause words to be misaligned if any word is longer than any other word by a few characters.
For example, I would like to have something like:
Name Last Name Middle initial
Bob Jones M
Joe ReallyLongLastName T
Instead, by including only ""'s in my cout statement I can only manage to get
Name Last Name Middle initial
Bob Jones M
Joe ReallyLongLastName T
or
Name Last Name Middle initial
Bob Jones M
Joe ReallyLongLastName T
What else would I need to do?
EDIT: So I get that I should first count the maximum width of each column I want displayed, and then adding padding spaces accordingly. But how, and with what functions, can I go about doing this? Should I simply count the number of chars in a string and then go from there?
See Question&Answers more detail:os