function
<cstdio>
renameint rename ( const char * oldname, const char * newname );
Rename file
Changes the name of the file or directory specified by oldname to newname.This is an operation performed directly on a file; No streams are involved in the operation.
If oldname and newname specify different paths and this is supported by the system, the file is moved to the new location.
If newname names an existing file, the function may either fail or override the existing file, depending on the specific system and library implementation.
Proper file access shall be available.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* rename example */
#include <stdio.h>
int main ()
{
int result;
char oldname[] ="oldname.txt";
char newname[] ="newname.txt";
result= rename( oldname , newname );
if ( result == 0 )
puts ( "File successfully renamed" );
else
perror( "Error renaming file" );
return 0;
}
File successfully renamed
Otherwise, a message similar to this will be written to stderr:
Error renaming file: Permission denied
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4