#include <stdio.h>
void readFile(char file[]) {
FILE *fp = fopen(file, "r");
char ch;
while ((ch = fgetc(fp)) != EOF)
putchar(ch);
fclose(fp);
}
void mergeFiles(char file1[], char file2[], char tofile[]) {
FILE *fp1 = fopen(file1, "r");
FILE *fp2 = fopen(file2, "r");
FILE *tofp = fopen(tofile, "w");
char ch;
while ((ch = fgetc(fp1)) != EOF)
fputc(ch, tofp);
fputc('\n', tofp);
while ((ch = fgetc(fp2)) != EOF)
fputc(ch, tofp);
fclose(fp1);
fclose(fp2);
fclose(tofp);
}
int main()
{
char file1[100] = "d:\\data1.txt";
char file2[100] = "d:\\data2.txt";
char tofile[100] = "d:\\data_copy.txt";
mergeFiles(file1, file2, tofile);
readFile(tofile);
return 0;
}
/*
run:
c c++ c#
java python
php javascript
nodejs
*/