首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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

返回值

函数调用之前的填充字符。

二次

代码语言:javascript
复制
#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';
}

二次

产出:

二次

代码语言:javascript
复制
With default setting :         40
Replaced ' ' with 'x': xxxxxxxx40

二次

另见

setfill

changes the fill character (function template)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com