[<<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()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson