名前空間
変種
操作

std::basic_ios<CharT,Traits>::fill

From cppreference.com
< cpp‎ | io‎ | basic ios
 
 
 
 
CharT fill() const;
(1)
CharT fill( CharT ch );
(2)

指定されたフィールド幅への出力変換を埋めるために使用されるフィル文字を管理します。

1) 現在のフィル文字を返します。
2) フィル文字を ch に設定し、フィル文字の以前の値を返します。

目次

[編集] パラメータ

文字 - フィル文字として使用する文字

[編集] 戻り値

関数の呼び出し前のフィル文字。

[編集]

#include <iomanip>
#include <iostream>
 
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]

[編集] 関連項目

埋め文字を変更する
(関数テンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)