.TH remove() "" "" "General Function (libc)"
.PC "Remove a file"
.B "#include <stdio.h>"
.B int
\fBremove(\fIfilename\^\fB)\fR
\fBconst char *\fIfilename\^\fB;\fR
.PP
.II "file, remove"
.II "remove a file"
.II unlink()
.B remove()
breaks the link between between
.I filename
and the actual file that it represents.
In effect, it removes a file.
Thereafter, any attempt to use
.I filename
to open that file will fail.
It is equivalent to the system call \fBunlink()\fR.
.PP
.B remove()
will remove a file that is currently open.
.B remove()
returns zero if it could remove
.IR filename ,
and nonzero if it could not.
.SH Example
This example removes the file named on the command line.
.DM
#include <stdio.h>
#include <stdlib.h>
.DE
.DM
main(argc,argv)
int argc, char *argv[])
{
	if(argc != 1) {
		fprintf(stderr, "usage: remove filename\en");
		exit(EXIT_FAILURE);
	}
.DE
.DM
	if(remove(argv[1])) {
		perror("remove failed");
		exit(EXIT_FAILURE);
	}
	return(EXIT_SUCCESS);
}
.DE
.SH "See Also"
.Xr "libc," libc
.Xr "unlink()" unlink
.br
\*(AS, \(sc7.9.4.1
.br
\*(PX Standard, \(sc8.1
