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>unlink() delete a file</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 unlink()                Delete a File

 #include   <io.h>                       Required for declarations only
 #include   <stdio.h>                    Use either io.h or stdio.h

 int        unlink(pathname);
 const char *pathname;                   Path name of file to be removed

    unlink() deletes a file identified by 'pathname'.

    Returns:    Zero, if successful.  On error, -1 is returned and
                'errno' is set to one of the following:

                    EACCES    Pathname specifies a directory or a
                              read-only file.
                    ENOENT    File name or path name not found.

 Portability:   Not supported by ANSI standard.

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

    The following example attempts to delete a file and prints an
    appropriate error message.

           #include <io.h>
           #include <stdlib.h>

           int result;

           main()
           {
                 result = unlink("info.bak");
                 if (result == -1)
                    perror("couldn't delete backup file");
                 else
                     printf("backup file deleted");
           }


See Also: close() remove()

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