Friday, March 17, 2023

C Programming. Program to copy the content of one file to another.

 Program to copy the content of one file to another.

//  Program to copy the content of one file to another.

#include<stdio.h>

int main() {
    FILE *f1, *f2;
    char c;
    f1 = fopen("File1.txt", "r");
    f2 = fopen ("File2.txt", "w");
    while ((c=getc(f1))!=EOF){
        putc(c, f2);
    }
    fclose(f1);
    fclose(f2);
    return 0;
}

Output :

File1:
Hello guys, This Program is to copy the content of file 1 to file 2.
File2:
Hello guys, This Program is to copy the content of file 1 to file 2.

No comments:

Post a Comment

Selection Sort Using C programming.

Selection sort is a simple and efficient sorting algorithm that works by repeatedly selecting the smallest (or largest) element from the un...