-
setwidth help
I am trying to create a graph similar to this
---------year ---------population1 ---------population2
### ####### #######
#### ##### #######
#### ###### #######
except perfectly aligned no matter what info is entered. This is for a C++ assignment due in an hour, I forgot my book, and I can't remember how to use setwidth. HELP!
I apparently can't get it to show up how I want it to on the forum - it should be 3 columns all aligned to the right with the year, followed by the 2 populations. the system will be created using a loop statement to recalculate the estimated population based on the year showing pop for every 5 years until it reaches 100 years
-
You should look it up -- google setw, or go to cplusplus.com and search there.
-
thanks, doing that now. But any extra help would still be great.
edit: got it
-
I believe you use it like this:
don't forget to include <iomanip>
cout << "Some text" << setwidth(5) << "Another text" << setwidth(5) << "Last text" << endl;
It adds some spacing. You may have to experiment with how long it should be.
-
got it working, thanks a lot. Assignment finished on time.