Erasing a File

Go to the Navigation pageHelpExitBackNext

The remove() Function
To erase a file, you use the library function remove().
 
Syntax
Its prototype is in STDIO.H, as follows:

int remove(const char *filename);
 
Argument
The variable *filename is a pointer to the name of the file to be erased. (See the section on filenames earlier in this unit.) The specified file must not be open. If the file exists, it is erased (just as if you used the DEL command from the DOS prompt) and remove() returns 0.
 
Return Value
If the file does not exist, is write-only, or some other error occurs, remove() returns -1.