【发布时间】:2021-02-05 01:22:12
【问题描述】:
今天学习了setfill()和#include<iomanip>中的其他方法,于是有了使用#include<iomanip>的练习。
我想在控制台上打印这个:
+--------------+ | Iomanip 示例 | +--------------+所以我写了这段代码:
cout << '+' << setfill('-') << setw(25) << '+' << endl;
cout << setw(26) << internal << "Iomanip Examples" << endl;
cout << '+' << setfill('-') << setw(25) << '+' << endl;
但我的控制台打印了这个:
+---------------+ //没关系。 ------Iomanip 例子 //nope.. +---------------+我认为当我使用setfill('-') 时,输出流中的空格会被'-' 字符填充。
我该如何解决这个问题?
【问题讨论】: