简体   繁体   English

Setfill和setw不起作用

[英]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. 基本上,我正在尝试setfill和setw创建一个固定表来显示存储在数组中的信息,但是似乎没有设置宽度在起作用,我不确定为什么。 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: 我得到的输出是:

在此处输入图片说明

Either increase the column width or use two rows. 增大列宽或使用两行。 The "Stock Description" has more than 10 letters. “股票描述”有10个以上的字母。 You should also allow for spaces between column titles. 您还应该在列标题之间留出空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM