Share via


#include <fstream.h>

The fstream class is an iostream derivative specialized for combined disk file input and output. Its constructors automatically create and attach a filebuf buffer object.

See filebuf class for information on the get and put areas and their associated pointers. Although the filebuf object’s get and put pointers are theoretically independent, the get area and the put area are not active at the same time. When the stream’s mode changes from input to output, the get area is emptied and the put area is reinitialized. When the mode changes from output to input, the put area is flushed and the get area is reinitialized. Thus, either the get pointer or the put pointer is null at all times.

Construction/Destruction — Public Members


Constructs an fstream object.


Destroys an fstream object.

Operations — Public Members


Opens a file and attaches it to the filebuf object and thus to the stream.


Flushes any waiting output and closes the stream’s file.


Attaches the specified reserve area to the stream’s filebuf object.


Sets the stream’s mode to binary or text.


Attaches the stream (through the filebuf object) to an open file.

Status/Information — Public Members


Gets the stream’s filebuf object.


Returns the file descriptor associated with the stream.


Tests whether the stream’s file is open.

Input Stream Classes

See Also   ifstream, ofstream, strstream, stdiostream, filebuf