The function remove (), as the name suggests, is used to erase a file. The prototype of remove () as given in Hove () stdio.h can be given as int remove (const char *filename);The remove() will erase the file specified by filename.
REMOVE
()
The
function remove (), as the name suggests, is used to erase a file. The
prototype of remove () as given in Hove () stdio.h can be given as
int remove (const char *filename);
The
remove() will erase the file specified by filename. On success, the function
will return zero and in case of error, it will return a non-zero value.
If
filename specifies a directory, then remove (filename) is the equivalent of
rmdir (filename). Otherwise, if filename specifies the name of a file then
remove (filename) is the equivalent of unlink (filename). Look at the program
given below which deletes the file "temp.txt" from the current
directory.
#include <stdio.h>
main()
{
remove ("temp.txt");
return 0;
}
Note
You
may specify the path of the file which has to be deleted as the argument of
remove () .
Programming in C: Unit V: File processing : Tag: : Syntax with Example C Program - Remove()
Programming in C
CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation