Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <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);
 char       *pathname;                   Path name of file to be removed

    unlink() deletes the file specified by 'pathname'.

    Returns:    Zero if the file is successfully deleted, or -1 if an
                error occurs.

                On error, '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.

  -------------------------------- 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()

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