Sun Jun 24 2018
Delete File
C Programming876 views
File Name: delete-file.c
#include<stdio.h>
int main() {
int status;
status = remove("newfile.txt");
/* Checking the file is deleted or not */
if(status == 0)
printf("File Deleted Successfully!\n");
else {
printf("Unable to delete the file!\n");
/* Print descriptive error message to stderr */
perror("Error");
}
return 0;
}
/* Output */
File Deleted Successfully!
/* ---------------------------------- */
Unable to delete the file!
Error: No such file or directory
Reference:
Author:Geekboots