Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>setmode() set file-translation mode</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
setmode()                Set File-Translation Mode

 #include   <io.h>                       Required for declarations only
 #include   <fcntl.h>

 int        setmode(handle,mode);
 int        handle;                      File handle
 int        mode;                        New translation mode

    setmode() sets the translation mode of the file associated with
    'handle' to 'mode'.  'mode' must be one of the following constants:

        O_TEXT      Text (translated) mode. In text mode,
                    carriage-return-line-feed combinations are translated
                    to a line-feed on input.  The line-feed characters
                    are translated back to a carriage-return and
                    line-feed on output.

        O_BINARY    Set binary (untranslated) mode.  The above
                    translations are suppressed.

    setmode() is typically used to modify the default translation mode of
    'stdin', 'stdout', 'stderr', 'stdaux', and 'stdout' (standard input,
    standard output, standard error, standard auxiliary, and standard
    printrt). 'stdin', 'stdaux', and 'stderr' streams are opened in text
    mode by default.  'stdaux' and 'stdprn' are opened in binary mode.
    setmode() can also be used on files and can be used to change the
    mode of a file after it has been opened.

    Returns:    The previous translation mode, if successful; or -1 if an
                error occurs. On error, 'errno' (defined in <stdlib.h>)
                is set to either:

                    EBADF     Invalid file handle, or
                    EINVAL    Invalid 'mode' argument.

  -------------------------------- Example ---------------------------------

    This example sets 'stdout' to binary mode.

          #include <stdio.h>
          #include <fcntl.h>
          #include <io.h>

          main()
          {
                int rslt;

                rslt = setmode(fileno(stdout),O_BINARY);
          }

See Also: creat() fopen() open()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson