c_-_c_files:file_merge
C - C++ Files - File merge
#include<iostream.h> #include<conio.h> #include<fstream.h> #include<stdio.h> void main() { clrscr(); char ch,st[100],cha,ts[100]; ofstream o("r.txt"); cout<<"\n Enter the contents of file1:"; do { ch=cin.get(); fflush(stdin); o.put(ch); } while(ch!='.'); o.close(); ofstream t("u.txt"); cout<<"\n Enter the contents fo file2:"; do { cha=cin.get(); fflush(stdin); t.put(cha); } while(cha!='.'); t.close(); ifstream i,j; i.open("r.txt"); j.open("u.txt"); fstream k; k.open("m.txt",ios::app); while(!i.eof()) { fflush(stdin); i.read((char*)&st,sizeof(st)); fflush(stdin); k.clear(); k.write((char*)&st,sizeof(st)); cout<<st; } while(!j.eof()) { fflush(stdin); j.read((char*)&ts,sizeof(ts)); fflush(stdin); k.clear(); k.write((char*)&ts,sizeof(ts)); cout<<ts; } getch(); }
c_-_c_files/file_merge.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1