rename

Gives a new name to an existing file.

Format

#include  <stdio.h>

int rename  (const char *old_file_spec, const char
            *new_file_spec);

Arguments

old_file_spec
A pointer to a string that is the existing name of the file to be renamed.
new_file_spec
A pointer to a string that is to be the new name of the file.

Description

If you try to rename a file that is currently open, the behavior is undefined. You cannot rename a file from one physical device to another. Both the old and new file specifications must reside on the same device.

If the new_file_spec does not contain a file extension, the file extension of old_file_spec is used. To rename a file to have no file extension, new_file_spec must contain a period (.) For example, the following renames SYS$DISK:[]FILE.DAT to SYS$DISK:[]FILE1.DAT:

rename("file.dat", "file1");

Whereas the following renames SYS$DISK:[]FILE.DAT to SYS$DISK:[]FILE1:

rename(file.dat", "file1.");

Return Values
Indicates success. 
nonzero value  Indicates failure. 


Previous Page | Next Page | Table of Contents | Index