Use C rename function to rename a file

Syntax

C rename function has the following syntax.

int rename(const char *oldfname, const char *newfname);

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;
}




















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h