Practical - 36
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream i1, i2;
ofstream o;
char ch;
i1.open("test1.txt");
i2.open("test2.txt");
if(i1==NULL || i2==NULL)
{
cout<<"error\n";
}
o.open("test3.txt");
if(!o)
{
cout<<"error in file";
}
while(i1.eof()==0)
{
i1>>ch;
o<<ch;
}
while(i2.eof()==0)
{
i2>>ch;
o<<ch;
}
cout<<"The two files were merged into test3.txt";
i1.close();
i2.close();
o.close();
return 0;
}
#include<fstream>
using namespace std;
int main()
{
ifstream i1, i2;
ofstream o;
char ch;
i1.open("test1.txt");
i2.open("test2.txt");
if(i1==NULL || i2==NULL)
{
cout<<"error\n";
}
o.open("test3.txt");
if(!o)
{
cout<<"error in file";
}
while(i1.eof()==0)
{
i1>>ch;
o<<ch;
}
while(i2.eof()==0)
{
i2>>ch;
o<<ch;
}
cout<<"The two files were merged into test3.txt";
i1.close();
i2.close();
o.close();
return 0;
}