Freigeben über


ios_base::openmode

Describes how to interact with a stream.

static const openmode app, ate, binary, in, out, trunc;

Remarks

The type is a bitmask type that describes an object that can store the opening mode for several iostreams objects. The distinct flag values (elements) are:

  • app, to seek to the end of a stream before each insertion.

  • ate, to seek to the end of a stream when its controlling object is first created.

  • binary, to read a file as a binary stream, rather than as a text stream.

  • in, to permit extraction from a stream.

  • out, to permit insertion to a stream.

  • trunc, to delete contents of an existing file when its controlling object is created.

Example

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

Requirements

Header: <ios>

Namespace: std

See Also

Concepts

ios_base Class

ios_base Members

iostream Programming

iostreams Conventions