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 6.0 - <b>_dos_close() close a file handle</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _dos_close()            Close a file handle

 #include   <dos.h>

  unsigned     _dos_close(handle);
  int handle;       File identifier

    _dos_close() uses MS-DOS function call 3Eh to close the file assigned
    to 'handle'. The handle is an identifier that was returned by the
    function that created or opened the file.

    Returns:    If successful _dos_close() returns 0, otherwise it
                returns the MS-DOS error code and sets errno to EBADF,
                indicating an invalid file handle.

      Notes:    _dos_close() can only be used with files that have been
                opened with one of the following functions: _dos_creat(),
                _dos_creatnew(), _dos_open(), creat(), or open(). It
                cannot be used with the stream creating or opening
                functions.

                _dos_close() updates the file's directory and writes to
                the file any partially filled internal buffers associated
                with it.

                In MS-DOS 3.0 or higher, dosexterr() can be used for
                extended error code information.

 Portability:   MS-DOS only, version 2.0 or higher

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

           This program closes a file opened with a file handle

           #include <dos.h>

           main()
           {
             int handle;
             unsigned err_code;
             .
             .  (File opened and used)
             .
             if (err_code = _dos_close(handle))
                printf("Unable to close handle %d\n", handle);
             else
                printf("Handle %d closed successfully\n", handle);

           }


See Also: _dos_creat() _dos_creatnew() _dos_open()

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