共用方式為


basic_ios::fill

指定或傳回要使用的字元,當文字不同寬度相同資料流。

char_type fill( ) const; 
char_type fill( 
   char_type _Char 
);

參數

  • _Char
    您要為字元填滿的字元。

傳回值

目前字元填滿。

備註

第 10% 成員函式傳回儲存的字元填滿。 第二 + 成成員函式在字元填滿儲存 _Char 並傳回其最後儲存的值。

範例

// basic_ios_fill.cpp
// compile with: /EHsc
#include <iostream>
#include <iomanip>

int main( ) 
{
   using namespace std;

   cout << setw( 5 ) << 'a' << endl;

   cout.fill( 'x' );
   cout << setw( 5 ) << 'a' << endl;

   cout << cout.fill( ) << endl;
}
  

需求

標題: <ios>

命名空間: std

請參閱

參考

basic_ios 類別

iostream 程式設計

iostreams 慣例