函式
<iomanip>

std::setfill

/*unspecified*/ setfill (char_type c);
設定填充字元
c 設定為流的填充字元

插入到流上的運算子(可以插入到輸出流)的行為如同呼叫了使用 c 作為引數的成員函式 fill

此操縱符在標頭檔案 <iomanip> 中宣告。

引數

c
流的新填充字元
char_type 是流使用的字元型別(即其第一個類模板引數 charT)。

返回值

未指定。此函式只應作為流操縱符使用(見示例)。

示例

1
2
3
4
5
6
7
8
9
// setfill example
#include <iostream>     // std::cout, std::endl
#include <iomanip>      // std::setfill, std::setw

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

輸出

xxxxxxxx77


資料競爭

插入該運算子的流物件將被修改。
對同一流物件的併發訪問可能會引發資料競爭。

異常安全

基本保證:如果丟擲異常,流處於有效狀態。

另見