Home > Backend Development > C++ > C program to delete files

C program to delete files

王林
Release: 2023-08-25 16:41:03
forward
2561 people have browsed it

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 in C programming

The remove function is used to delete the file with the specified name. This function is located in the stdio header file.

Syntax

remove (“file_name”);
Copy after login

Parameters

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.

Return value

Returns zero if the delete operation completes successfully; otherwise returns a non-zero value on failure.

Example

#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;
}
Copy after login

Output

The file is Deleted successfully
Copy after login

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!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template