bool is_open() const;
true if a previous call to member open succeeded and there have been no calls to member close since.true if a file is open and associated with this file stream buffer object.false otherwise.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// filebuf::is_open() example
#include <iostream>
#include <fstream>
int main () {
std::ifstream is;
std::filebuf * fb = is.rdbuf();
fb->open ("test.txt",std::ios::in);
if ( fb->is_open() )
std::cout << "the file is open.\n";
else
std::cout << "the file is not open.\n";
fb->close();
return 0;
}