iostream hierarchy filebuf:: is_open |
cplusplus.com |
Check if file is open.
The function returns true if a previous call to
open succeeded and there have been no
calls to member close since, meaning that the
filebuf object is currently associated with a file.
Parameters.
Return Value.
true if a file is open.
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> ):
bool is_open ( ); |
See also.
close,
open
filebuf class