[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


rename

Change the name of a file.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdio.h>
int rename(const char *old, const char *new);
Parameters:

Parameters for this facility are:

old  
const char *  
The old file name  
new  
const char *  
The new file name  

Remarks:

The rename() function changes the name of a file, specified by old to the name specified by new.

Return:

rename() returns a nonzero if it fails and returns zero if successful

See Also:

"freopen"

"remove"

Example of rename() usage.:
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	char oldname[50];	// current filename
	char newname[50];	// new filename
	
	// get the current filename from the user
	printf("Please enter the current filename.\n");
	gets(oldname);

	// get the new filename from the user
	printf("Please enter the new filename.\n");
	gets(newname);
	
	// rename oldname to newname
	if (rename(oldname, newname) != 0) {
		printf("Can't rename %s to %s.\n", oldname,
		  newname);
		exit(1);
	}

	return 0;
}

Output:
Please enter the current filename.
metrowerks
Please enter the new filename.
itwerks


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000