.
Previous

Write a C program to copy contents from one file to another file ?

/*  C Program for copy file contents */
#include<stdio.h>
#include<conio.h>

int main(){
    char ch,source[100],dest[100];
    FILE *sp,*dp;
    clrscr();
    printf("Enter Sourse file : ");
    scanf("%s",source);
    printf("Enter The Destination file : ");
    scanf("%s",dest);

    sp = fopen(source,"r");
    dp = fopen(dest,"w");

    while((ch=fgetc(sp))!=EOF){
       fputc(ch,dp);
    }

    fclose(sp);
    fclose(dp);

    return 0;

}
Previous