AnkitWebLogic

Copy File Content | File handling

Ex6. WAP to copy contents of one file into another file, filename is entered by user. 1

#include<stdio.h>
void main()
{
    char ch, filename[20];
    FILE *fp, *fp2;
    printf("Enter filename: ");
    gets(filename);
    fp=fopen(filename,"r");
    fp2=fopen("newfile.txt","w");
    do{
        ch=fgetc(fp);
        if(ch==EOF)
            break;
        fputc(ch, fp2);
    }while(1);
    fclose(fp);
    fclose(fp2);
}
Enter filename: file1.txt
There is no quick way to learn any programming language
You need practice to learn coding
The more you practice the better you will be.