Compartilhar via


ios_base::seekdir

Specifies starting point for offset operations.

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

Remarks

The type is an enumerated type that describes an object that can store the seek mode used as an argument to the member functions of several iostream classes. The distinct flag values are:

  • beg, to seek (alter the current read or write position) relative to the beginning of a sequence (array, stream, or file).

  • cur, to seek relative to the current position within a sequence.

  • end, to seek relative to the end of a sequence.

Example

// 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";
}

Contents of File

aestinga

Requirements

Header: <ios>

Namespace: std

See Also

Reference

ios_base Class

iostream Programming

iostreams Conventions

Other Resources

ios_base Members