www.delorie.com/djgpp/doc/libc/libc_707.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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 the signals SIGINT and SIGQUIT when you press, respectively, Ctrl-C and Ctrl-\ (Ctrl-BREAK will still cause SIGINT), because many programs that use binary reads from the console will also want to get the `^C' and `^\' keys. You can use the __djgpp_set_ctrl_c library function (see section __djgpp_set_ctrl_c) if you want Ctrl-C and Ctrl-\ to generate signals 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

ANSI/ISO C No
POSIX No

Example

 
setmode(0, O_BINARY);


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004