目录

setfill

描述 (Description)

C ++函数std::setfill行为就好像使用c作为参数调用成员填充一样,它作为操纵std::setfill插入到流上(它可以插入到输出流中)。

它用于将c设置为流的填充字符。

声明 (Declaration)

以下是std :: setfill函数的声明。

setfill (char_type c);

参数 (Parameters)

c - 流的新填充字符。 char_type是流使用的字符类型(即,其第一个类模板参数charT)。

返回值 (Return Value)

它返回未指定。 此功能仅应用作流操纵器。

异常 (Exceptions)

Basic guarantee - 如果抛出异常,则流处于有效状态。

数据竞争 (Data races)

它所插入的流对象被修改。 对同一流对象的并发访问可能会引入数据争用。

例子 (Example)

在下面的例子中解释了setfill功能。

#include <iostream>
#include <iomanip>
int main () {
   std::cout << std::setfill ('x') << std::setw (10);
   std::cout << 77 << std::endl;
   return 0;
}

让我们编译并运行上面的程序,这将产生以下结果 -

xxxxxxxx77
↑回到顶部↑
WIKI教程 @2018