Function Description:
Delete a name from the file system. If the name is the last connection to the file and no other process opens the file, the file corresponding to the name will be deleted.
Usage:
# Include <unistd. h>
Int unlink (const char * pathname );
Parameters:
Pathname: Specifies the name of the file to be unbound.
Return description:
0 is returned when execution is successful. -1 is returned for failure, and errno is set to one of the following values
Eacces: insufficient power
Efault: the memory space is not accessible.
EIO: An input/output error occurs.
Eisdir: the pathname index is a directory.
Eloop: too many symbolic connections exist in the path parsing process.
Enametoolong: the path name exceeds the allowed length.
Enoent: the directory does not exist or is suspended.
Enomem: insufficient core memory
Enotdir: Part of the path name is not a directory.
Eperm: The file system does not support unconnecting files or directories. It may also be permitted by the permission step.
Erofs: File System read-only
# Include
# Include
Int main (void)
{
File * fp = fopen ("junk. Kaplan", "W ");
Int status;
Fprintf (FP, "junk ");
Status = access ("junk. hh", 0 );
If (status = 0)
Printf ("file exists/N ");
Else
Printf ("file doesn't exist/N ");
Fclose (FP );
Unlink ("junk. Kaplan ");
Status = access ("junk. hh", 0 );
If (status = 0)
Printf ("file exists/N ");
Else
Printf ("file doesn't exist/N ");
Return 0;
}