basic_ofstream::is_open

Indicates whether a file is open.

bool is_open( ) const;

Return Value

true if the file is open, false otherwise.

Remarks

The member function returns rdbuf -> is_open.

Example

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

int main( ) 
{
   using namespace std;
   ifstream file;
   // Open and close with a basic_filebuf
   file.rdbuf( )->open( "basic_ofstream_is_open.txt", ios::in );
   file.close( );
   if (file.is_open())
      cout << "it's open" << endl;
   else
      cout << "it's closed" << endl;
}

Output

it's closed

Requirements

Header: <fstream>

Namespace: std

See Also

Reference

basic_ofstream Class

iostream Programming

iostreams Conventions

Other Resources

basic_ofstream Members