Cpp-standard-library-cpp-ostream-flush

提供:Dev Guides
2020年6月22日 (月) 19:03時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

C ++ Ostreamライブラリ-フラッシュ

説明

出力ストリームバッファをフラッシュし、関連するストリームバッファを制御された出力シーケンスと同期するために使用されます。

宣言

以下は、std
ostream :: flushの宣言です。
ostream& flush();

パラメーター

none

戻り値

ostreamオブジェクト(* this)を返します。

例外

基本保証-例外がスローされた場合、オブジェクトは有効な状態です。

データの競合

ストリームオブジェクトを変更します。

以下の例では、std
ostream :: flushについて説明しています。
#include <fstream>

int main () {

   std::ofstream outfile ("test.txt");

   for (int n=0; n<100; ++n) {
      outfile << n;
      outfile.flush();
   }
   outfile.close();

   return 0;
}