@node setmode, io @subheading Syntax @example #include int setmode(int file, int mode); @end example @subheading Description This function sets the mode of the given @var{file} to @var{mode}, which is either @code{O_TEXT} or @code{O_BINARY}. It will also set the file into either cooked or raw mode accordingly, and set any @code{FILE*} objects that use this file into text or binary mode. When called to put @var{file} that refers to the console into binary mode, @code{setmode} will disable the generation of the signals @code{SIGINT} and @code{SIGQUIT} when you press, respectively, @kbd{Ctrl-@key{C}} and @kbd{Ctrl-@key{\}} (@kbd{Ctrl-@key{BREAK}} will still cause @code{SIGINT}), because many programs that use binary reads from the console will also want to get the @samp{^C} and @samp{^\} keys. You can use the @code{__djgpp_set_ctrl_c} library function (@pxref{__djgpp_set_ctrl_c}) if you want @kbd{Ctrl-@key{C}} and @kbd{Ctrl-@key{\}} to generate signals while console is read in binary mode. Note that, for buffered streams (@code{FILE*}), you must call @code{fflush} (@pxref{fflush}) before @code{setmode}, or call @code{setmode} before writing anything to the file, for proper operation. @subheading Return Value When successful, the function will return the previous mode of the given @var{file}. In case of failure, -1 is returned and @var{errno} is set. @subheading Portability @portability !ansi, !posix @subheading Example @example setmode(0, O_BINARY); @end example