共用方式為


ios_base::seekdir

位移作業的識別開頭。

namespace std {
   class ios_base {
   public:
      typedef implementation-defined-enumerated-type seekdir;
      static const seekdir beg;
      static const seekdir cur;
      static const seekdir end;
      ...
   };
}

備註

這個型別是描述物件可以儲存為引數使用的搜尋模式的 iostream 類別的成員函式的其中一個列舉型別。 不同的旗標值為:

  • beg,尋找 (修改讀取或寫入目前位置) 的相對順序 (陣列、資料流或檔案的開頭。

  • cur,尋找相對於在序列中的目前位置。

  • end,尋找相對於序列的結尾。

範例

// ios_base_seekdir.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";
   file.seekp( 0, ios_base::beg );
   file << "a";
   file.seekp( 0, ios_base::end );
   file << "a";
}

檔案的內容。

aestinga

需求

標題: <ios>

命名空間: std

請參閱

參考

ios_base Class

iostream 程式設計

iostreams 慣例