I'm having a tough time trying to figure out what the heck is wrong with my code.
If anyone would like to help, that'd be cool.
here's my code.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void renamefile( void );
int main()
{
int input;
for( input = 0; input <= 2; input++)
{
printf(">>>> 1. Rename file\n");
printf(">>>> 2. Exit Program\n");
printf("\nEnter selection: ");
scanf("%d", &input);
if( input == 1 )
{
printf("Entering Rename file. . .\n");
renamefile();
if( input == 2 )
{
printf("Exit program...\n");
exit(0);
}
}
}
return input;
}
void renamefile( void )
{
char oldname[80], newname[80];
printf("Enter current filename: ", oldname);
gets(oldname);
printf("Enter new filename: ", newname);
gets(newname);
if( rename( oldname, newname ) == 0)
printf("File %s has been rename to %s.\n", oldname, newname);
else
fprintf(stderr, "Somethings screwed.\n");
}
When it compiles, it's all good and dandy then when I execute it it outputs this
>>>> 1. Rename file
>>>> 2. Exit program
Enter Selection: 1
Entering Rename file. . .
Enter current filename: Enter new filename:
As you can see, it's not exactly doing what i want it to...
Any suggestions?
Thanks
Russ.