AnkitWebLogic

Copy File | File handling

Ex5. WAP to copy contents of one file into another file. 1

#include<stdio.h>
void main()
{
    char ch;
    FILE *fp, *fp2;
    fp=fopen("file1.txt","r");
    fp2=fopen("file2.txt","w");
    do{
        ch=fgetc(fp);
        if(ch==EOF)
            break;
        fputc(ch, fp2);
    }while(1);
    fclose(fp);
    fclose(fp2);
}
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.
file2.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.