C Language: rename function(Rename File)

In the C Programming Language, the rename function changes the name of a file. You must close the file before renaming, as a file can not be renamed if it is open.


The syntax for the rename function in the C Language is:

int rename(const char *old, const char *new);

Parameters or Arguments


The old file name that will be changed.


The new file name to use.


The rename function returns zero is successful, otherwise nonzero.

Required Header

In the C Language, the required header for the rename function is:

#include <stdio.h>

Applies To

In the C Language, the rename function can be used in the following versions:

  • ANSI/ISO 9899-1990

stdio.h Functions