SPRUIG8J January 2018 – March 2024
Rename File
#include {<stdio.h> | <file.h>}
int rename (const char *old_name , const char *new_name );
#include {<cstdio> | <file.h>}
int std::rename (const char *old_name , const char *new_name );
The rename function changes the name of a file.
The optional device specified in the new name must match the device of the old name. If they do not match, a file copy would be required to perform the rename, and rename is not capable of this action.
The function returns one of the following values:
0 | if successful |
-1 | on failure |
Although rename is a low-level function, it is defined by the C standard and can be used by portable applications.