setf

提供:cppreference.com
< cpp | io
移動: 案内, 検索


文法:

    fmtflags stream::setf( fmtflags フラグ );
    fmtflags stream::setf( fmtflags フラグ, fmtflags 必要なフラグ );

setf()関数は現在のストリームのio_stream_format_flagsに対して"フラグ"を設定します。追加の"必要なフラグ"は、"フラグ"と、"必要なフラグ"の両方にセットされたフラグのみを設定します。返り値は以前の設定値のio_stream_format_flagsです。

サンプル:

     int number = 0x3FF;
     cout.setf( ios::dec );
     cout << "10進: " << number << endl;
     cout.unsetf( ios::dec );
     cout.setf( ios::hex );
     cout << "16進: " << number << endl;

前のコードは、マニピュレータのおかげで次のコードと同じ結果になります。

     int number = 0x3FF;
     cout << "10進: " << number << endl << hex << "16進: " << number
  << dec << endl;

関連トピック: flags, unsetf

個人用ツール
名前空間
変種
操作
案内
ツールボックス