Writing from two files to a single file

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <fstream>
#include <string>

int main()
{
	using namespace 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;
}
Topic archived. No new replies allowed.