/* Copyright (c) 2001-2004 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that renames the file specified as the first 
command line argument to that specified by the second command 
line argument. this program rename.c is executed by command
       rename.c < rename.in
   Input file rename.in contains the following data: rename.c temp
*/
#include <stdio.h>

int main() {
    char name1[80], name2[80];

    printf("Enter filename: ");
    scanf("%s", name1);
    printf("%s\n", name1);
    printf("Enter new name: ");
    scanf("%s", name2);
    printf("%s\n", name2);
    if(rename(name1, name2)!=0) 
        printf("Rename error\n");
    else {
	printf("Old file name: %s\n",name1); 
	printf("New file name: %s\n", name2);
    }
    if(rename(name2, name1) !=0) 
        printf("Rename error\n");
    else {
	printf("Old file name: %s\n", name2); 
	printf("New file name: %s\n", name1); 
    }
    return (0);
}
