Delete File
C Programming ⚭ Jun 6, 2016 ⚭ 31 views
#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
Learn more about File I/O in C