Answer to Question #305718 in C for Shree

Question #305718

Write a C code to merge the contents of the file abc.txt and xyz.txt and save it another file called merge.txt.

1
Expert's answer
2022-03-03T14:52:26-0500
#include <stdio.h>

int main() {
    FILE *fin, *fout;
    int ch;

    fin = fopen("abc.txt", "r");
    fout = fopen("merge.txt", "w");

    while ((ch = fgetc(fin)) != EOF) {
        fputc(ch, fout);
    }
    fclose(fin);

    fin = fopen("xyz.txt", "r");

    while ((ch = fgetc(fin)) != EOF) {
        fputc(ch, fout);
    }
    fclose(fin);
    fclose(fout);

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS