Next Previous Contents

3.160 rename

Function

Rename a file.

Header

stdio.h

Declaration

int __fastcall__ rename (const char* oldname, const char* newname);

Description

rename renames a file (gives it a new name). On success, zero is returned. On error, -1 is returned and errno is set to an error code describing the reason for the failure.

Limits

  • This function is not available on all cc65 targets (depends on the capabilities of the storage devices).
  • The function is only available as fastcall function, so it may only be used in presence of a prototype.

Availability

ISO 9899

See also

remove

Example

#include <stdio.h>

#define OLDNAME "textfile.txt"
#define NEWNAME "textfile.bak"

if (rename (OLDNAME, NEWNAME) == 0) {
    printf ("Renamed %s to %s\n", OLDNAME, NEWNAME);
} else {
    printf ("Error renaming %s to %s\n", OLDNAME, NEWNAME);
}


Next Previous Contents