Menu
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

C stdio rename() Function

❮ C stdio Library


Example

Rename a file:

rename("filename.txt", "newfile.txt");

Definition and Usage

The rename() function changes the name of a file. If the operating system supports it, this function can also be used to move a file to a different directory.

The rename() function is defined in the <stdio.h> header file.


Syntax

rename(const char * oldname, const char * newname);

Parameter Values

Parameter Description
oldname Required. A string containing the path and filename of the file being renamed.
newname Required. A string containing the new path and filename for the file.

Technical Details

Returns: An int value which is zero if the file was successfully renamed. If an error occurred then a value other than zero is returned.

❮ C stdio Library