We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.
#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