Write a program To merge two File

/*
    To merge two File
*/
#include<iostream>
#include<fstream>
using namespace std;

int main()
{
    ifstream f1,f2;
    ofstream f3("Merge.txt",ios::binary);

    f1.open("File 1.txt",ios::binary);
    f2.open("File 2.txt",ios::binary);

    char c;

    f1.get(c);
    while(!f1.eof())
    {
        f3<<c;
        f1.get(c);
    }


    f2.get(c);
    while(!f2.eof())
    {
        f3<<c;
        f2.get(c);
    }

    /*
        cout<<"\n\n Position: "<<f1.seekg(5);
        cout<<"\n\n Position: "<<f3.tellp();
    */

    cout<<"\n\n Copied Sucessfully!! ";
    f1.close();
    f2.close();
    f3.close();
    return 0;
}

Previous
Next Post »