C stdio rename() Function
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. |
---|