Syntax
#include <stdio.h> int remove(const char *filename);Description
remove deletes the file specified by filename.
Note: You cannot remove a nonexistent file or a file that is open.
remove returns 0 if it successfully deletes the file. A nonzero return value idicates an error.
This example uses remove to remove a file. It issues a message if an error occurs.
#include <stdio.h> int main(void) { char *FileName = "file2rm.mjq"; FILE *fp; fp = fopen(FileName, "w"); fprintf(fp, "Hello world\n"); fclose(fp); if (remove(FileName) != 0) perror("Could not remove file"); else printf("File \"%s\" removed successfully.\n", FileName); return 0; /**************************************************************************** The output should be: File "file2rm.mjq" removed successfully. ****************************************************************************/ }Related Information