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");
             }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster