This section illustrates you to rename a file in C. You can see in the given example that we want to replace the name of the text file MYFILE.txt with HELLO.txt. For this, we have used the library function rename() which renames the file MYFILE.txt to HELLO.txt. In case if the file some how, not be renamed, the function perror() prints the error message.
Here is the code:
When you run the above example, the file MYFILE.txt is renamed to HELLO.txt. File MYFILE.txt should be placed where your RENAMEFI.C File is present.
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: February 5, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles