Write a program to copy from one file to another.
Input and Output Format:
Refer sample input and output for formatting specifications.
All text in bold corresponds to input and the rest corresponds to output.
Sample Input and Output:
Enter the input file name
testInput.txt
Enter the output file name
testOutput.txt
Code:
#include<stdio.h>
int main(){
FILE *fp1, *fp2;
char fname1[50],fname2[50],ch;
printf("Enter the input file name\n");
scanf("%s",fname1);
printf("Enter the output file name\n");
scanf("%s",fname2);
fp1=fopen(fname1,"r");
fp2=fopen(fname2,"w");
while((ch=getc(fp1))!=EOF)
{
putc(ch,fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}
No comments:
Post a Comment