You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
740 B
C

#include<stdio.h>
#include<stdlib.h>
void main()
{
FILE *fp1,*fp2,*fp3;
char ch;
int tc=0,tw=1;
fp1=fopen("file1.txt","r");
if(fp1==NULL)
{
printf("File doesn't exist\n");
exit(1);
}
fp2=fopen("file2.txt","r");
if(fp2==NULL)
{
printf("File doesn't exist\n");
exit(1);
}
fp3=fopen("file3.txt","w");
while(!feof(fp1))
{
ch=getc(fp1);
putc(ch,fp3);
}
fclose(fp1);
while(!feof(fp2))
{
ch=getc(fp2);
putc(ch,fp3);
}
fclose(fp2);
fclose(fp3);
printf("file1 and file2 are concatenated in file3")
}