std::basic_ios::fill
CharT fill() const;  | (1)  |   | 
|---|---|---|
CharT fill( CharT ch );  | (2)  |   | 
管理用于将输出转换到指定字段宽度的填充字符。
1%29返回当前填充字符。
2%29将填充字符设置为ch,返回填充字符的前一个值。
参数
ch  | -  | the character to use as fill character  | 
|---|
返回值
函数调用之前的填充字符。
例
二次
#include <iostream>
#include <iomanip>
 
int main ()
{
  std::cout << "With default setting : " << std::setw(10) << 40 << '\n';
  char prev = std::cout.fill('x');
  std::cout << "Replaced '" << prev << "' with '"
            << std::cout.fill() << "': " << std::setw(10) << 40 << '\n';
}二次
产出:
二次
With default setting :         40
Replaced ' ' with 'x': xxxxxxxx40二次
另见
setfill  | changes the fill character (function template)  | 
|---|
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

