Compiling despair!!!

Alright. As the title indicates, I have a compiling problem. Any help is much appreciated! Here is the result of compiling:




1>------ Build started: Project: Merge Program, Configuration: Debug Win32 ------
1> Source.cpp


1>c:\users\vok\documents\visual studio 2012\projects\merge program\merge program\source.cpp(19): error C2660: 'merge' : function does not take 3 arguments

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========








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
#include <iostream>
#include <fstream>
using namespace std;


int merge(int merge(ifstream &, ifstream &, ofstream));

	int a, b, e;
	ifstream file1, file2;
	ofstream file3;

void main()
{

	file1.open("\\file1.txt");  
	file2.open("\\file2.txt");
	file3.open("\\file3.txt");

	e = merge(file1, file2, file3);
  
	

	if (e != 0)

		cout << "Files failed to merge. Make sure both files contain useable data. ";
	else
		cout << "Files were merged successfully!  ";


	file1.close();
	file2.close();
	file3.close();

	system("PAUSE");
	return;

}

int merge(int MERGE(ifstream &file1, ifstream &file2, ofstream &file3))
{
	while ((!file1.eof()) && (!file2.eof()))
	{
	file1 >> a;
	file2 >> b; 



	if (a < b)
	
		file3 << a << b;
	else
		file3 << b << a;
	
	
	if ((a > 0) && (b > 0))

		e = 0;
	else

		if (a <= 0)
			e = 1;
		else
			
			if (b <= 0)
				e = 2;
			else
				e = 0;
	}
	return e;
}
Last edited on
closed account (j3Rz8vqX)
For starters:

Double up on every single '\' from lines 13-15; looks like you've started, but continue it to the three remaining.

Following that, there is an error with your passing of std::ios_base data types.
I recommend passing these explicit data types as reference:
1
2
3
4
5
//Line 5:
int merge(ifstream &, ifstream &, ofstream &); 

//Line 37:
int MERGE(ifstream &file1, ifstream &file2, ofstream &file3)


Lastly, I've always had an error when not calling main with a return type of integer. If this isn't an issue for you, by all means, leave it as it is.


Good Luck.
Last edited on
http://en.cppreference.com/w/cpp/algorithm/merge


Now is time for a good lesson why not to have using namespace std;

From the link above, you can see std::merge is something else entirely.

Also C++ is case sensitive, so merge and MERGE are two different functions. Not really a good idea IMO to do that.

What does the merge function do?

As the title indicates, I have a debugging problem. Any help is much appreciated! Here is the result of debugging:


This is compiling: debugging is when one steps through code, that does compile, one line at a time while keeping an eye on the value of variables to see where the problem is.

Hope all is well at your end :+)
Thanks so much for your help both of you. I really appreciate it.

I updated the code...

Almost done with compiling! (thank you TheIdeasMan for setting me straight on terminology)
I'm actually down to one error!

I think line 19 contains incorrect syntax. What do you guys think?
It is the line that is highlighted when I click on the error msg in Visual Studio...
closed account (j3Rz8vqX)
Your function prototype should be like this:
1
2
//Line 5:
int merge(ifstream &, ifstream &, ofstream);


Your function should be:
1
2
//Line 39
int merge(ifstream &file1, ifstream &file2, ofstream &file3)


Your previous error was due to Merge != merge; I copied/pasted and also produced that error in my previous post - it was intended that both the function and its prototype have identical names.

Naming convention is case sensitive; upper and lower cases.
Last edited on
Topic archived. No new replies allowed.