Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdio.h>
    FILE *fdopen( int handle, const char *mode );
    FILE *_wfdopen( int handle, const wchar_t *mode );

Description:
    The fdopen function associates a stream with the file handle handle
    which represents an opened file or device.  The handle was returned by
    one of  creat,  dup,  dup2,  open, or  sopen.  The open mode mode must
    match the mode with which the file or device was originally opened.

    The argument mode is described in the description of the  fopen
    function.

    The _wfdopen function is identical to fdopen except that it accepts a
    wide character string for the second argument.

Returns:
    The fdopen function returns a pointer to the object controlling the
    stream.  This pointer must be passed as a parameter to subsequent
    functions for performing operations on the file.  If the open operation
    fails, fdopen returns a NULL pointer.  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()
      {
        int handle;
        FILE *fp;

        handle = open( "file", O_RDONLY | O_TEXT );
        if( handle != -1 ) {
          fp = fdopen( handle, "r" );
          if( fp != NULL ) {
            /*
                process the stream
            */
            fclose( fp );
          } else {
            close( handle );
          }
        }
      }

Classification:
    fdopen is POSIX 1003.1, _wfdopen is not POSIX

Systems:
     fdopen - All, Netware

    _wfdopen - All

See Also:
    creat, dup, dup2, fopen, freopen, _fsopen, open, sopen

See Also: dup2

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