std::setfill
Defined in header <iomanip> | | |
---|---|---|
template< class CharT > /*unspecified*/ setfill( CharT c ); | | |
在表达式中使用时out << setfill(c)
设置流的填充字符。out
到c
...
参数
c | - | new value for the fill character |
---|
返回值
返回未指定类型的对象,以便在out
类型的输出流的名称。std::basic_ostream<CharT, Traits>
,然后表达out << setfill(n)
行为就像执行了以下代码:
out.fill(n);
注记
std::ostream::fill
...
例
二次
#include <iostream>
#include <iomanip>
int main()
{
std::cout << "default fill: " << std::setw(10) << 42 << '\n'
<< "setfill('*'): " << std::setfill('*')
<< std::setw(10) << 42 << '\n';
}
二次
产出:
二次
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) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com