ios_base::openmode

說明如何將與資料互動。

namespace std {
   class ios_base {
   public:
      typedef implementation-defined-bitmask-type iostate;
      static const iostate badbit;
      static const iostate eofbit;
      static const iostate failbit;
      static const iostate goodbit;
      ...
   };
}

備註

描述物件可以儲存數 iostreams 物件的開頭模型的型別是 bitmask type 。不同的旗標值 (項目) 是:

  • 應用程式,搜尋到資料流末端才不會在每個貼上。

  • ate,搜尋到資料流結尾,則會在它的控制項物件第一次建立。

  • binary,將檔案當做二進位資料流,而不是文字資料流。

  • in,允許從資料流的擷取。

  • out,允許插入至資料流。

  • trunc,刪除現有檔案的內容,當控制項所建立的物件。

範例

// ios_base_openmode.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

int main ( ) 
{
   using namespace std;
   fstream file;
   file.open( "rm.txt", ios_base::out | ios_base::trunc );

   file << "testing";
}

需求

標題: <ios>

命名空間: std

請參閱

參考

ios_base Class

iostream 程式設計

iostreams 慣例