broliverparker
broliverparker

Reputation: 217

Setfill and setw not working

Basically I am trying to setfill and setw to create a fixed table to display information stored in an array however it doesn't appear that set width is working and I'm not sure why. Here is the code I am using:

const int MAXWIDTH = 10;
cout << left << setw(MAXWIDTH) << setfill(' ') << "Stock Number";
cout << left << setw(MAXWIDTH) << setfill(' ') << "Stock Description";
cout << left << setw(MAXWIDTH) << setfill(' ') << "Order Level";
cout << left << setw(MAXWIDTH) << setfill(' ') << "Reorder Level";

The output I get is:

enter image description here

Upvotes: 1

Views: 1330

Answers (1)

Thomas Matthews
Thomas Matthews

Reputation: 57678

Either increase the column width or use two rows. The "Stock Description" has more than 10 letters. You should also allow for spaces between column titles.

Upvotes: 1

Related Questions