I'm having trouble aligning some text with setw and the left alignment. I'm not sure if it has something to do with the fact that I'm printing from a function. The text within quotes aligns fine, but the output from the function aligns to the right and screws up the placement of the text after it. Here's my code:
void playerReadout(vector<player> players, int numOfPlayers)
{
for(int i = 0;i < numOfPlayers;i++)
{
cout << "Player #" << (i + 1) << " - (" << players[i].getName() << ")" << endl;
cout << "---------" << endl;
cout << setw(20) << left << "HP: " << players[i].getCurrHP() << "/" << players[i].getMaxHP();
cout << " ";
cout << setw(20) << left << "Bloodied: " << players[i].getBloodied() << endl;
cout << setw(20) << left << "Surge Value: " << players[i].getSurgeValue();
cout << " ";
cout << setw(20) << left << "Surges Left: " << players[i].getSurges() << endl;
cout << "AC: " << players[i].getAC() << endl
<< "Fortitude: " << players[i].getFort() << endl
<< "Reflex: " << players[i].getRef() << endl
<< "Will: " << players[i].getWill() << endl;
cout << "Initiative Bonus: " << players[i].getInit() << endl;
cout << "Statuses: ";
players[i].printStatuses();
cout << endl;
cout << "---------" << endl;
cout << endl;
}
}
And here's the output I'm having trouble with:
Player #1 - (Rolen)
----------
HP: 54/59Bloodied: 29
Surge Value: 14Surges Left: 3
AC: 22
Fortitude: 17
Reflex: 20
Will: 18
Initiative Bonus: 8
Statuses: None
----------
I'm trying to get 2 side-by-side width 20 sections in each row, and have the entries aligned with the one below it. I don't know how to describe it better than that.
Does anyone know what's wrong?