Name
unlink - Deletes a file.
Syntax
#include <io.h>
#include <stdio.h>
int unlink(path)
const char *path;
Description
The unlink function deletes the file specified by path.
Return Value
If successful, unlink returns 0; otherwise, it returns -1
and sets errno to one of the following constants:
Value Meaning
EACCES Path name specifies a directory or a read-only file
ENOENT File or path name not found
See Also
close(S), remove(DOS)
Example
#include <io.h> #include <stdlib.h> #include <stdio.h>
main()
{
int result = unlink("tmpfile");
if (result == -1)
perror("Couldn't delete tmpfile");
else
printf( "Link successfully removed
'tmpfile'.\n" );
} This program uses unlink to delete a file named tmpfile.
(printed 6/18/89)