ios_base::seekdir

Specifies starting point for offset operations.

static const seekdir beg, cur, 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

Concepts

ios_base Class

ios_base Members

iostream Programming

iostreams Conventions