Go to the first, previous, next, last section, table of contents.


setmode

Syntax

#include <io.h>

int setmode(int file, int mode);

Description

This function sets the mode of the given file to mode, which is either O_TEXT or O_BINARY. It will also set the file into either cooked or raw mode accordingly, and set any FILE* objects that use this file into text or binary mode.

When called to put file that refers to the console into binary mode, setmode will disable the generation of SIGINT when you press Ctrl-C (Ctrl-Break will still cause SIGINT), because many programs that use binary reads from the console will also want to get the `^C' characters. You can use the __djgpp_set_ctrl_c library function (see section __djgpp_set_ctrl_c) if you want Ctrl-C to generate interrupts while console is read in binary mode.

Note that, for buffered streams (FILE*), you must call fflush (see section fflush) before setmode, or call setmode before writing anything to the file, for proper operation.

Return Value

When successful, the function will return the previous mode of the given file. In case of failure, -1 is returned and errno is set.

Portability

not ANSI, not POSIX

Example

setmode(0, O_BINARY);


Go to the first, previous, next, last section, table of contents.