std::rename (3) - Linux Manuals
std::rename: std::rename
NAME
Synopsis
Defined in header <cstdio>
int rename( const char *old_filename, const char *new_filename );
Changes the filename of a file. The file is identified by character string pointed to by old_filename. The new filename is identified by character string pointed to by new_filename.
If new_filename exists, the behavior is implementation-defined.
Parameters
old_filename - pointer to a null-terminated string containing the path identifying the file to rename
new_filename - pointer to a null-terminated string containing the new path of the file
Return value
0 upon success or non-zero value on error.
Notes
POSIX specifies many additional details on the semantics of this function, which are reproduced in C++ by std::experimental::filesystem::rename.
Example
// Run this code
Output:
See also
rename moves or renames a file or directory
(C++17)
remove (function)