I have a program that prints out inventory which is formatted so that its lined up on the right like so:
Code:
Strawberries
Watermelons
Bananas
using the following code:
Code:
for (iter=items.begin(); iter!=items.end(); iter++)
cout<<setw(30)<<right<<(*iter)<<endl;
What I want to do now is to add a grid reference to where the items are. The grid reference is to be written like (x,y) and I want to put it in front of the item when printing the list, but I want to keep the list lined up on the right 30 spaces over, but obviously:
Code:
for (iter=items.begin(); iter!=items.end(); iter++)
cout<<setw(30)<<right<<"("<<iter->x<<","<<iter->y<<") "<<(*iter)<<endl;
will just line up the "(" 30 spaces over. Is there an easy way to do this?