Help with error C2665

Can anyone help me I have an error on line 22. It says error C2665 no instance of overloaded function matches the argument list

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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
#include <cmath>
#include <fstream>
#include <string>

using namespace std;

// Prototypes
void Start_up();
void get_array_values(int[], int);
int get_array_values(int[], int, fstream&);
void Mean(int, int);

const int ARRAY_SIZE = 100;

int main()
{
	ifstream ifile;
	ofstream ofile;
	string filename;
	int array1[ARRAY_SIZE] = { 1, 2, 3 };
	int number_of_values = ||| get_array_values(array1, ARRAY_SIZE, ifile); |||
	Start_up();
	system("pause");
	system("cls");

	cout << "		Please enter the name of the input file" << endl
		<< "		in which the list of numbers is found." << endl;
	getline(cin, filename);

	int sum = 0;

	for (int i = 0; i < number_of_values; i++)
	{
		cout << array1[i] << endl;
		sum += array1[i];
	}
	Mean(sum, number_of_values);

	ifile.open(filename, fstream::in);
		if (ifile.is_open())
		{
			cout << "		File " << filename << " was found.";
			ifile.close();
		}
		else if (!ifile.is_open())
		{
			cout << "		Unable to open file "<< filename;
			return 1;
		}

		ofile.open("Data.txt");

		ofile.close();

	return 0;
}

void Start_up()
{
	cout << endl << endl;
	cout << "			Hello and Welcome" << endl
		<< "		     to the Math Calculator !" << endl
		<< endl
		<< "		  Do you have a list of numbers" << endl
		<< "		and want to be able to find the" << endl
		<< "		Average, Maximum, Median, Minimum," << endl
		<< "		Mode, and Std deviation of that list" << endl
		<< "		well worry no more this program does" << endl
		<< "		just that so sit back and relax." << endl;
}

void get_array_values(int array1[], int array_size)
{
	for (int i = 0; i < array_size; i++)
	{
		cout << "Enter number " << i + 1 << ": ";
		cin >> array1[i];
		cout << endl;
	}
}

int get_array_values(int array1[], int array_size, fstream &ifile)
{
	int size;
	ifile >> size;
	//	cout << endl << "Size = " << size << endl;
	if (size > array_size)
	{
		cout << "This is an invalid input File." << endl;
		cout << "size was bigger than " << array_size << endl;
		exit(2);
	}
	for (int i = 0; i < size; i++)
	{
		ifile >> array1[i];
		if (ifile.eof())
		{
			cout << "This is an invalid input File." << endl;
			cout << "The size was larger than " << i << endl;
			exit(3);
		}
	}
	return size;
}


void Mean(int sum, int number_of_values)
{
	double mean = 0;

	mean = (static_cast <double> (sum)) / number_of_values;

	cout << "The average is " << mean << endl;
}
Last edited on
int get_array_values(int[], int, fstream&);
Try changing the 3rd parameter from fstream& to ifstream&
Also don't forget to put ifstream& on line 83 too.
Thanks that worked. I'm Still new to C++.
Topic archived. No new replies allowed.