名稱空間
變體
操作

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

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

管理用於填充輸出轉換到指定欄位寬度的填充字元。

1) 返回當前的填充字元。
2) 將填充字元設定為 ch,返回填充字元的先前值。

目錄

[編輯] 引數

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]

[編輯] 參閱

更改填充字元
(函式模板) [編輯]