fstream

#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

fstream

Constructs an fstream object.

~fstream

Destroys an fstream object.

Operations — Public Members

open

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

close

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

setbuf

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

setmode

Sets the stream’s mode to binary or text.

attach

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

Status/Information — Public Members

rdbuf

Gets the stream’s filebuf object.

fd

Returns the file descriptor associated with the stream.

is_open

Tests whether the stream’s file is open.

Input Stream Classes

See Also   ifstream, ofstream, strstream, stdiostream, filebuf