Is this possible?

I want to make a sort of tabel.
like:
1
2
Team 1             1 point
Team 23            3 points   


Where all the points are neatly under each other. setw() doesn't work because not all the team names are the same length
Yes, setw is there for that.
eg:
1
2
3
4
    string a="team 1", b="team 1000";
    int sa = 10, sb = 1;
    cout << setw(10) << left << a << setw(2) << right << sa << (sa==1?" point":" points") << endl;
    cout << setw(10) << left << b << setw(2) << right << sb << (sb==1?" point":" points") << endl;
team 1    10 points
team 1000  1 point
but I want them both to the right..

EDIT: found how to do it. But why in the beginning setw(10)?
Last edited on
It was a random number, you can make it whatever you want
Ok, but how does that make it work?
10 is the maximum number of characters that will be filled. It must be larger than the length of the thing you are going to print or you won't notice any change
Topic archived. No new replies allowed.