Write a C code to merge the contents of the file abc.txt and xyz.txt and save it another file called merge.txt.
#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;
}
Comments
Leave a comment