Ok so i have to print a table of data like so..
SURNAME LAST NAME ADDRESS POSTCODE
right?

but the problem is the text won't align to the appropriate heading.
so when i try to use tabs if someone has a longer surname or whatever this happens.

SURNAME\t      LAST NAME\t    ADDRESS\t\t\t             POSTCODE
Smith          John          123 Fake St                   1234
Somelongname                  John        124 Some St   2345

Or something.
Can someone help me align the headings.
i.e.

Smith         John        123 Fake St                   1234
Somelongname  John        124 Some St                  2345

I hope i explained the problem well enough.
Thanks

Recommended Answers

All 3 Replies

Don't use tabs, you will always have that problem that way. Instead use the std::setw std::left io manipulators

IOW, look up the iomanip settings

yes use the sed width functions within the #include<iomanip>....google it to find out more

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.