Compartir a través de


basic_ofstream::is_open

Indica si un archivo está abierto.

bool is_open( ) const;

Valor devuelto

true si el archivo está abierto, false de otra manera.

Comentarios

La función miembro devuelve rdbuf - > is_open.

Ejemplo

// 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

Requisitos

encabezado: <fstream>

espacio de nombres: std

Vea también

Referencia

basic_ofstream Class

programación iostream

convenciones de iostreams