Use C rename function to rename a file
Syntax
C rename function has the following syntax.
int rename(const char *oldfname, const char *newfname);
Header
C rename function is from header file stdio.h.
Description
C rename function changes the file name.
C rename function returns zero on success or nonzero on error.
Example
Use C rename function to rename a file.
#include <stdio.h>
/*ww w .j a va2 s . c om*/
int main(int argc, char *argv[])
{
if(rename("oldName", "newName") != 0){
printf("Rename Error");
}
return 0;
}