Deletes the specified file.
Include
<stdio.h>
Prototype
int remove(const char *filename);
Argument
filename |
name of file to be deleted |
Return Value
Returns 0 if successful; otherwise, returns -1.
Remarks
If filename
does not exist or is open, remove will fail.
Example
#include <stdio.h> /* for remove, printf */
int main(void)
{
if (remove("myfile.txt") != 0)
printf("Cannot remove file");
else
printf("File removed");
}
Example Output
File removed