cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : filebuf : close
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
filebuf
filebuf::filebuf
filebuf::~filebuf
member functions:
· filebuf::close
· filebuf::is_open
· filebuf::open
virtual members:
· filebuf::imbue
· filebuf::overflow
· filebuf::pbackfail
· filebuf::seekoff
· filebuf::seekpos
· filebuf::setbuf
· filebuf::showmanyc
· filebuf::sync
· filebuf::uflow
· filebuf::underflow

-

filebuf::close public member function
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

// 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

filebuf::open Open file (public member function)
filebuf::is_open Check if a file is open (public member function)

Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us