Deletes a file.
#include <stdio.h> int remove(const char *filename);
filename
A pointer to a character string containing the name of a file.
The remove() function deletes the named file specified by filename. remove() returns 0 if the file deletion is successful, and returns a nonzero value if it fails.
#include <stdio.h> #include <stdlib.h> int main(void) { char filename[40]; // get a filename from the user printf("Enter the name of the file to delete.\n"); gets(filename); // delete the file if (remove(filename) != 0) { printf("Can't remove %s.\n", filename); exit(1); } return 0; }