Home >Backend Development >C++ >C program to delete files
In programming, processing files is very important. Each programming language has its own set of functions or libraries to help manipulate files.
In the C programming language, there is also a function called remove that programmers can use to delete files.
The remove function is used to delete the file with the specified name. This function is located in the stdio header file.
remove (“file_name”);
This function accepts one parameter, which is the name of the file to be deleted.
The file name can also be the path of the file, but only if the system supports it.
Returns zero if the delete operation completes successfully; otherwise returns a non-zero value on failure.
#include<stdio.h> int main() { int del = remove("textFile.txt"); if (!del) printf("The file is Deleted successfully"); else printf("the file is not Deleted"); return 0; }
The file is Deleted successfully
The above is the detailed content of C program to delete files. For more information, please follow other related articles on the PHP Chinese website!