C Programming
Computer Programming

C file handling program to rename a file using the rename() function



Write C file handling program to rename a file using the rename() function

\* C file handling program to rename a file using the rename() function *\

# include < stdio.h >
int   main( )
{

char oldName[25] ;
char newName[25] ;
int ret = 0 ;
printf("\n Enter old filename: ") ;
scanf("%s", oldName ) ;
printf("\n Enter new filename: ") ;
scanf("%s", newName ) ;

ret = rename(oldName, newName ) ;
if (ret == 0)
      printf(" File renamed successfully !\n") ;
else
      printf(" Unable to rename file !\n") ;
return 0;

}

Output of Program :

Output of C file handling program to rename a file using the rename() function