Renames the specified file.
Include
<stdio.h>
Prototype
int rename(const char * old, const char * new);
Arguments
old | |
new |
Return Value
Return 0 if successful; otherwise, returns a non-zero value.
Remarks
The old name must exist in the current working directory. The new name must not already exist in the current working directory.
Example
#include <stdio.h>
int main(void)
{
if (rename("myfile.txt","newfile.txt") != 0)
printf("Cannot rename file");
else
printf("File renamed");
}
Example Output
File renamed