filebuf::is_open |
public member function |
Check if a file is open
The function returns true if a previous call to open succeeded and there have been no calls to the member close since, meaning that the filebuf object is currently associated with a file.
Parameters
none
Return Value
true if a file is open, i.e. associated to this stream buffer object.
false otherwise.
Example
// is_open () example
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream is;
filebuf * fb;
fb = is.rdbuf();
fb->open ("test.txt",ios::in);
if ( fb->is_open() )
cout << "file is open.\n";
else
cout << "file is not open.\n";
fb->close();
return 0;
}
|
Basic template member declaration
( basic_filebuf<charT,traits> )
See also