Name

rename

Synopsis

Renames or moves a file

#include <stdio.h>
intrename( const char *oldname, const char *newname );

The rename() function changes the name of the file specified by oldname to the string referenced by newname. The pointer argument oldname must refer to the name of an existing file.

The function returns 0 on success. If rename() fails to rename the file, it returns a nonzero value.

Example

See the example for remove() in this chapter.

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.