remove
raw OCR
Removes a file.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
int remove(const char *filename);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
remove deletes the file specified by filename. It is a macro that simply translates its call to a call to unlink. If your file is open, be sure to close it before removing it.
^t^
The string pointed to by ^filename may include a full DOS path.
Return value
On successful completion, remove returns 0. On error, it returns -1, and the global variable errno is set to one of the following:
ENOENT No such file or directory EACCES Permission denied
See also
Example
#include <stdio.h>
int main(void)
char file[80];
/* prompt for file name to delete */
printfC'File to delete: ");
gets(file);
/* delete the file */
if (remove(file) == 0)
printf("Removed %s. \n",file);
else
perror("remove" );
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdio.h/remove/
· short form /3.1/remove/