Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>_close() close a file handle</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _close()                Close a File Handle

 #include   <io.h>

 int        _close(handle);
 int        handle;                      Handle associated with file

    _close() closes a file associated with a file handle, 'handle'
    previously obtained with a _creat(), creat(), creatnew(),
    creattemp(), dup(), dup2(), _open() or open() call.  _close() does
    not cause a 'Ctrl-Z' character to be written at the end of a text
    file when it is closed.

       Returns:     0, if successful.  On error, -1 is returned. If
                    'handle' is not a valid open file handle, 'errno'
                    (defined in <errno.h>) is set to EBADF (bad file
                    number).

   Portability:     MS-DOS only.

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

    The following statements create the file "MYNAME.DAT" and write a
    name to the file and close it without writing a ctrl-Z.  This
    produces a file with only the characters of the name in it.


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

           main()
           {
               int handle;

               if ((handle = open("myname.dat",O_RDWR|O_CREAT)) != -1) {
                   write(handle,"GERTRUDE HASSENFRAS",19);
                   _close(handle);
               }
               else {
                   perror("error opening myname");
               }
           }


See Also: close() creat() fclose()

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