
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u>
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
#include <io.h>
#include <fcntl.h>
int setmode( int handle, int mode );
Description:
The setmode function sets, at the operating system level, the
translation mode to be the value of mode for the file whose file handle
is given by handle. The mode, defined in the <fcntl.h> header file, can
be one of:
Mode Meaning
O_TEXT
On input, a carriage-return character that immediately precedes a
linefeed character is removed from the data that is read. On output, a
carriage-return character is inserted before each linefeed character.
O_BINARY
Data is read or written unchanged.
Returns:
If successful, the setmode function returns the previous mode that was
set for the file; otherwise, -1 is returned. When an error has
occurred, errno contains a value indicating the type of error that has
been detected.
Example:
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
void main()
{
FILE *fp;
long count;
fp = fopen( "file", "rb" );
if( fp != NULL ) {
setmode( fileno( fp ), O_BINARY );
count = 0L;
while( fgetc( fp ) != EOF ) ++count;
printf( "File contains %lu characters\n",
count );
fclose( fp );
}
}
Classification:
WATCOM
Systems:
All, Netware
See Also:
chsize, close, creat, dup, dup2, eof, exec Functions, filelength,
fileno, fstat, isatty, lseek, open, read, sopen, stat, tell, write,
umask
See Also: chsize dup2
Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson