basic_ofstream::is_open
指出檔案是否為開啟狀態。
bool is_open( ) const;
傳回值
true ,如果檔案是開啟的,則為 false 。
備註
範例
// 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
需求
標題: <fstream>
命名空間: std