Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ setw()在我的代码上工作不正常_C++ - Fatal编程技术网

C++ setw()在我的代码上工作不正常

C++ setw()在我的代码上工作不正常,c++,C++,我的代码有问题,不确定是错误还是代码有问题 #include <iostream> #include <iomanip> using namespace std; int main() { cout << setfill('*') << setw(80) << "*"; cout << setw(21) << "Mt.Pleasant Official Billing Statement" <<

我的代码有问题,不确定是错误还是代码有问题

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
cout << setfill('*') << setw(80) << "*";
cout << setw(21) <<  "Mt.Pleasant Official Billing Statement" << endl;
cout << setfill('*') << setw(80) << "*" << endl;
return 0;
}
#包括
#包括
使用名称空间std;
int main()
{
cout不移动文本,但设置文本的最小宽度

为了实现您的想法,您应该尝试使用更大的值,因为您的字符串长度超过21个字符,例如

cout << setfill('*') << setw(80) << "*" << endl;
cout  << setfill(' ') << setw(56) <<  "Mt.Pleasant Official Billing Statement" << endl;
cout << setfill('*') << setw(80) << "*" << endl;

如果你特别想要21个额外的空间或者什么的,把它们放进去。
********************************************************************************
                  Mt.Pleasant Official Billing Statement
********************************************************************************