#include <stdio.h>
#include <stdlib.h>
int main()
{
char ch;
char file1[20];
char file2[20];
FILE *fp;
FILE *fp1;
printf("Enter name of file to copy\n");
gets(file1);
fp = fopen(file1, "r");
if( fp == NULL )
{
// printf("Press any key to exit...\n");
}
printf("Enter name of target file\n");
gets(file1);
fp1 = fopen(file2, "w");
if(fp1 == NULL )
{
fclose(fp);
printf("Press any key to exit...\n");
}
while( ( ch = fgetc(fp) ) != EOF )
fputc(ch, fp1);
printf("File copied successfully.\n");
fclose(fp);
fclose(fp1);
system("pause");
return 0;
}
#include <stdlib.h>
int main()
{
char ch;
char file1[20];
char file2[20];
FILE *fp;
FILE *fp1;
printf("Enter name of file to copy\n");
gets(file1);
fp = fopen(file1, "r");
if( fp == NULL )
{
// printf("Press any key to exit...\n");
}
printf("Enter name of target file\n");
gets(file1);
fp1 = fopen(file2, "w");
if(fp1 == NULL )
{
fclose(fp);
printf("Press any key to exit...\n");
}
while( ( ch = fgetc(fp) ) != EOF )
fputc(ch, fp1);
printf("File copied successfully.\n");
fclose(fp);
fclose(fp1);
system("pause");
return 0;
}