I created a simple program that writes some text to two different text files. Could someone show me how to create a program that would retrieve the information from those two files, and put them in a single file, first the content of input1 and then the content of input2. I am really needing help learning how to do this.
Here is the program that I created that creates the two files. I really need help with this today, this is a lab for college, and I missed the day that he did the lecture on this.
#include <iostream>
#include <fstream>
#include <string>
int main()
{
usingnamespace std;
string input1;
ofstream fout("input1.txt");
fout<<"This is the first line in input1.txt.\n";
cout<<"The first line was added to input1"<<endl;
fout<<"This is the second line in input1.txt.\n";
cout<<"The second line was added to input1"<<endl;
fout<<"This is the third line in input1.txt.\n";
cout<<"The third line was added to input1"<<endl;
fout<<"This is the fourth line in input1.txt.\n";
cout<<"The fourth line was added to input1"<<endl;
fout.close();
fout.open("input2.txt");
fout<<"This is the first line in input2.txt.\n";
cout<<"The first line was added to input2"<<endl;
fout<<"This is the second line in input2.txt."<<endl;
cout<<"The second line was added to input2"<<endl;
fout<<"This is the third line in input2.txt."<<endl;
cout<<"The third line was added to input2"<<endl;
fout.close();
cin.get();
cin.get();
return 0;
}