This function is compatible with the following targets:
|
EMB/RTOS
|
|
#include <stdio.h>
int rename(const char *old, const char *new);Parameters:
Parameters for this facility are:
The rename() function changes the name of a file, specified by old to the name specified by new.
rename() returns a nonzero if it fails and returns zero if successful
#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