Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Make Two File Data Copy Another File Like Merge Data
- #include<conio.h>
- #include<stdio.h>
- void main()
- {
- FILE *fp1, *fp2,* fp3;
- char ch;
- clrscr();
- //Create FirstFile.txt in C:/TurboC3/BIN
- fp1=fopen("File1.txt","r");
- if(fp1==0)
- {
- printf("\n First File Opening Error");
- }
- //Create SecondFile.txt in C:/TurboC3/BIN
- fp2=fopen("File2.txt","r");
- if(fp2==0)
- {
- printf("\n Second File Opening Error");
- }
- fp3=fopen("Student.txt","w");
- if(fp3==0)
- {
- printf("\n Third File Creating Error");
- }
- ch=fgetc(fp1);
- //Copy FirstFile Data in ThirdFile.txt
- while(ch!=EOF)
- {
- fputc(ch,fp3);
- ch=fgetc(fp1);
- }
- //FirstFile.txt Copy After Add New Line
- fputc('\n',fp3);
- ch=fgetc(fp2);
- //Copy SecondFile.txt Data in ThirdFile.txt
- while(ch!=EOF)
- {
- fputc(ch,fp3);
- ch=fgetc(fp2);
- }
- //SecondFile.txt Copied in ThirdFile.txt
- fcloseall();
- printf("\n FirstFile And SecondFile Merged in ThirdFile");
- getch();
- }
Add Comment
Please, Sign In to add comment