Format
#include <fcntl.h> #include <io.h> int _setmode(int handle, int mode);
Language Level: Extension
_setmode sets the translation mode of the file
given by handle to mode. The mode
must be one of the values in the following table:
| Value | Meaning |
| O_TEXT | Sets the translated text mode. Carriage-return line-feed combinations are translated into a single line feed on input. Line-feed characters are translated into carriage-return line-feed combinations on output. |
| O_BINARY | Sets the binary (untranslated) mode. The above translations are suppressed. |
Use _setmode to change the translation mode of a file handle. The translation mode only affects the read and write functions. _setmode does not affect the translation mode of streams.
If a file handle is acquired other than by a call to open, creat, _sopen or fileno, you should call _setmode for that file handle before using it within the read or write functions.
Return Value
_setmode returns the previous translation
mode if successful. A return value of -1 indicates an error, and
errno is set to one of the following values:
| Value | Meaning |
| EBADF | The file handle is not a handle for an open file. |
| EINVAL | Incorrect mode (neither O_TEXT nor O_BINARY) |
![]()
creat -- Create New File
open -- Open File
_sopen -- Open
Shared File
read -- Read Into
Buffer
write -- Writes
from Buffer to File
<fcntl.h>
<io.h>
<share.h>
<sys\stat.h>