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

std::setfill

Defined in header <iomanip>

?

?

template< class CharT > /*unspecified*/ setfill( CharT c );

?

?

在表达式中使用时out << setfill(c)设置流的填充字符。outc...

参数

c

-

new value for the fill character

返回值

返回未指定类型的对象,以便在out类型的输出流的名称。std::basic_ostream<CharT, Traits>,然后表达out << setfill(n)行为就像执行了以下代码:

out.fill(n);

注记

std::ostream::fill...

二次

代码语言:javascript
复制
#include <iostream>
#include <iomanip>
int main()
{
    std::cout << "default fill: " << std::setw(10) << 42 << '\n'
              << "setfill('*'): " << std::setfill('*')
                                  << std::setw(10) << 42 << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
default fill:         42
setfill('*'): ********42

二次

另见

fill

manages the fill character (public member function of std::basic_ios)

internalleftright

sets the placement of fill characters (function)

setw

changes the width of the next input/output field (function)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com