#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp1 = fopen("F:/file1.txt", "r");
FILE *fp2 = fopen("F:/file2.txt", "r");
FILE *fp3 = fopen("F:/file3.txt", "w");
char c;
if (fp1 == NULL || fp2 == NULL || fp3 == NULL)
{
puts("Either file is not available or there there is something incorrect. Please check it...");
exit(0);
}
while ((c = fgetc(fp1)) != EOF)
fputc(c, fp3);
while ((c = fgetc(fp2)) != EOF)
fputc(c, fp3);
printf("The data of the file1 and file2 has been merged.");
fclose(fp1);
fclose(fp2);
fclose(fp3);
return 0;
}
Comments