fstream();
fstream( const char* szName, int nMode, int nProt = filebuf::openprot );
fstream( filedesc fd );
fstream( filedesc fd, char* pch, int nLength );
Parameters
szName
The name of the file to be opened during construction.
nMode
An integer that contains mode bits defined as ios enumerators that can be combined with the bitwise OR ( | ) operator. The nMode parameter must have one of the following values:
Note that there is no ios::in or ios::out default mode for fstream objects. You must specify both modes if your fstream object must both read and write files.
nProt
The file protection specification; defaults to the static integer filebuf::openprot, which is equivalent to the operating system default, filebuf::sh_compat, under MS-DOS. The possible nProt values are as follows:
The filebuf::sh_read and filebuf::sh_write modes can be combined with the logical OR ( || ) operator.
fd
A file descriptor as returned by a call to the run-time function _open or _sopen. filedesc is a typedef equivalent to int.
pch
Pointer to a previously allocated reserve area of length nLength. A NULL value (or nLength = 0) indicates that the stream will be unbuffered.
nLength
The length (in bytes) of the reserve area (0 = unbuffered).
Remarks
The four fstream constructors are:
All fstream constructors construct a filebuf object. The first three use an internally allocated reserve area, but the fourth uses a user-allocated area. The user-allocated area is not automatically released during destruction.