Files and reference function

I declared my function prototype but I keep getting multiple errors when compiling . Any help?

here are the errors.

project6.cpp: In function ‘int main()’:
project6.cpp:16: error: ‘if_stream’ was not declared in this scope
project6.cpp:16: error: expected ‘;’ before ‘file1’
project6.cpp:17: error: expected ‘;’ before ‘file2’
project6.cpp:18: error: ‘of_stream’ was not declared in this scope
project6.cpp:18: error: expected ‘;’ before ‘file3’
project6.cpp:24: error: ‘exit’ was not declared in this scope
project6.cpp:31: error: ‘exit’ was not declared in this scope
project6.cpp:34: error: ‘file1’ was not declared in this scope
project6.cpp:35: error: ‘file2’ was not declared in this scope
project6.cpp:43: error: ‘file3’ was not declared in this scope
project6.cpp:50: error: ‘file3’ was not declared in this scope
project6.cpp:58: error: ‘file3’ was not declared in this scope
project6.cpp:65: error: ‘file3’ was not declared in this scope

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 #include <iostream>
#include <fstream>
using namespace std;

void Mix(const ifstream& file1, const ifstream& file2, ofstream& file3);


int main()
{

	int num1, num2;

	ifstream in_stream;
	ofstream out_stream;

	if_stream file1("file1.txt");
	if_stream file2("file2.txt");
	of_stream file3("file3.txt");

	in_stream.open ("file1.txt");
	if (in_stream.fail())
	{
	cout << "The input file had an opening error.\n";
	exit(1);
	}
 
	out_stream.open ("file3.txt");
	if (out_stream.fail())
	{
	cout << "The output file had an opening error.\n";
	exit(1);
	}

	file1 >> num1;
	file2 >> num2;

	while (file1 || file2)
	{

	if (file1 && num1 < num2)
	{

	file3 << num1 <<endl;
	file1 >> num1;

	}
	else if (file2 &&  num2 < num1)
	{

	file3 << num2 <<endl;
	file1 >> num2;

	}
	else if (file1)
	{

	file1 >> num1;
	file3 << num1 <<endl;

	}
	else 
	{

	file2 >> num2;
	file3 << num2 <<endl;

	}
}

	in_stream.close();
	out_stream.close();
} 

//Definition of a function

void Mix(const ifstream& file1, const ifstream& file2, ofstream& file3);
if_stream and of_stream should be ifstream and ofstream respectively.

To use exit requires #include <cstdlib>
Thanks!
Topic archived. No new replies allowed.