This section illustrates you to delete a file in C. You can see in the given
example that we want to remove the file HELLO.txt. For this, we have used
the library function remove() which deletes the file HELLO.txt. In case if the
file will not be deleted, the function perror() prints the error message on
the console.
Here i am using TurboC++ IDE and my source file is in the C:\TC\BIN
directory and the file to be deleted Hello.txt should be first
placed inside the same bin directory.
Here is the code:
FILEDELE.C
#include <stdio.h>
|
When you run the above example, the file HELLO.txt gets removed.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: C file delete example
Post your Comment