_setmode

Change the mode a file.

int _setmode (int handle, int mode);

int setmode (int handle, int mode);

Required Header
<io.h>

Return Value

Each of these functions returns the old mode of the file. -1 indicates an error.

Parameters

handle

  A handle to the open file

mode

  The new mode for the file

Remarks

The _setmode function changes the mode of the file specified by handle to the value of mode which may be one of the following constant values:

_O_TEXT or O_TEXT,
_O_BINARY or O_BINARY
Although it is permissable to change the mode of a file after data has been written or read, it can cause unexpected results due to the buffering machanism employed. For this reason, it is best if the mode only be changed before data is written or read.

The likely use for the _setmode function it to change the mode of the standard handles for stdin, stdout or stderr.

Low Level I/O

See Also    _close, _dup, _dup2, _fileno, fopen, _open