public member function

std::filebuf::close

<fstream>
filebuf * close ( );
Close file
Closes the file currently associated with the object and disassociates it.

Any pending output sequence is written to the physical file. This is done by calling virtual member overflow.

The function fails if no file is currently open (associated) with this object.

Parameters

none

Return Value

In case of success, the function returns this.
In case of failure, a null pointer is returned.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// filebuf::close ()
#include <iostream>
#include <fstream>
using namespace std;

int main () {

  ifstream is;
  filebuf * fb;

  fb = is.rdbuf();
  fb->open ("test.txt",ios::in);

  // >> file buffer operations here <<

  fb->close();

  return 0;
}


Basic template member declaration

( basic_filebuf<charT,traits> )
 
basic_filebuf* close ( );


See also