1

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

broliverparker
  • 217
  • 2
  • 15

1 Answers1

1

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.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154