C Programming

Delete File

Learn C programming for delete file from the current directory

6/24/2018
0 views
delete-file.cC
#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
C languageC programmingDelete File

Related Examples