any help would be greatly appreciated

so first the software I am using is Microsoft visual studios....but here is the program I need to write --> Write a program that merges the numbers in two files and writes the results to a third file. The program reads input from two different files and writes the output to a third file. Each input file contains a list of integers in ascending order. After the program is executed, the output file contains the numbers from the two input files in one longer list, also in ascending order. Your program should define a function with three arguments: one for each of the two input file streams and one for the output file stream. The input files should be named numbers1.txt and numbers2.txt, and the output file should be named output.txt.

Some test cases that you may want to consider include the following:

• What if one of the files contains no numbers?
• What if both of the files contain no numbers?
• What happens if one of the files has many more numbers than the other?
• What happens if there are several blank lines after the last number in both files?
• What happens if there are no blank lines, spaces, or characters of any sort after the last number in each file?

**********The code bellow is what I have thus far. Can anyone help me to see if I am missing anything I need in the code I have with the given information above

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <fstream>
using namespace std;

int main() {
	ifstream fin1;
	ifstream fin2;
	ofstream fout;
	fin1.open ("numbers1.txt");
	if (fin1.fail()) {
		cout << "Input file opening failed.\n";
		exit(1);
	}
	fin2.open ("numbers2.txt");
	if (fin2.fail()) {
		cout << "Input file opening failed.\n";
		exit(1);
	}
	fout.open ("output.txt");
	if (fout.fail()) {
		cout << "Output file opening failed.\n";
		exit(1);
	}
	int a, b;
	fin1 >> a;
	fin2 >> b;
	while (! fin1.eof() && ! fin2.eof()) {
		if (a == b) {
			fout << a << endl;
			fout << b << endl;
			fin1 >> a;
			fin2 >> b;
		}
		if (b > a) {
			fout << a << endl;
			fin1 >> a;
		}
		if (a > b) {
			fout << b << endl;
			fin2 >> b;
		}
	}
	while (! fin1.eof()) {
		fout << a << endl;
		fin1 >> a;
	}
	while (! fin2.eof()) {
		fout << b << endl;
		fin2 >> b;
	}
	fin1.close();
	fin2.close();
	fout.close();
}
I would use getline() instead of >> as you can handle errors better.
im not quite sure what you mean...could you show me where to incorporate that into my code?
????
john here is video that might help you out http://thenewboston.org/watch.php?cat=16&number=72
bucky has great tutorials
Topic archived. No new replies allowed.