_setmode (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Sets the file translation mode.

int _setmode( 
inthandle,intmode);

Parameters

  • handle
    File handle.
  • mode
    New translation mode.

Return Values

If successful, _setmode returns the previous translation mode. A return value of –1 indicates an error.

Remarks

These functions are supported by all versions of the C run-time libraries.

The _setmode function sets to mode the translation mode of the file given by handle. The mode must be one of two manifest constants, _O_TEXT or _O_BINARY. _O_TEXT sets text (translated) mode.

Carriage return–linefeed (CR-LF) combinations are translated into a single linefeed character on input.

Linefeed characters are translated into CR-LF combinations on output. _O_BINARY sets binary (untranslated) mode, in which these translations are suppressed.

_setmode is typically used to modify the default translation mode of stdin and stdout, but you can use it on any file. If you apply _setmode to the file handle for a stream, call _setmode before performing any input or output operations on the stream.

Example

Description

This program uses _setmode to change stdin from text mode to binary mode.

Code

#include <stdlib.h>
#include <fcntl.h>

void main( void )
{
   int result;

   /* Set "stdin" to have binary mode: */
   result = _setmode( _fileno( stdin ), _O_BINARY );
   if( result == -1 )
      printf( "Cannot set mode" );
   else
      printf( "'stdin' successfully changed to binary mode\n" );
}

Output

'stdin' successfully changed to binary mode

Requirements

OS Versions: Windows CE 2.0 and later.

Header: stdlib.h.

Link Library: coredll.dll.

See Also

fopen

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.