Just a few simple problems. C2664 error

Ugh. I can't figure out why this keeps giving me the C2664 error. :/
all 4 errors tell me that it cannot convert parameter 1 from datatype[100] to datatype.
What am i doing wrong?


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




void inputData(string, double, int);
void displayPlayerData(string, double, int);
double calculateAvgScore(double, int);
void displayBelowAvg(double, string, double);


int main()
{
	const int SIZE=100;
	string playerName[SIZE];
	double playerScore[SIZE], AverageScore=0;
	inputData(playerName, playerScore, SIZE);
	displayPlayerData(playerName, playerScore, SIZE);
	AverageScore=calculateAvgScore(playerScore, SIZE);
	displayBelowAvg(AverageScore, playerName, playerScore);
}

void inputData(string names[], double score[], int size)
{
	//input player name and score
	int counter=0;
	while(counter<size)
	{
		cout<<"Enter player name or type 'Q' to quit: ";
		cin>>names[counter];
		if(names[counter]=="Q"||names[counter]=="q")
		{
			break;
		}
		cout<<"Enter score: ";
		cin>>score[counter];
		counter++;
	}
}

void displayPlayerData(string names[], double score[], int size)
{
	//display the name and score of each player
	int counter=0;
	while(counter<size)
	{
		cout<<"Name: "<<names[counter]<<endl;
		cout<<"Score: "<<score[counter]<<endl;
	}
}

double calculateAvgScore(double score[], int size)
{
	//calculate avg score and return it by value
	double totalScore, totalAverage;
	int counter=0;
	while(counter<size)
	{
		totalScore=totalScore+score[counter];
		counter++;
	}
	totalAverage=totalScore/counter;
	cout<<totalAverage;
	return totalAverage;
}

void displayBelowAvg(double AvgScore, string names[], double score[])
{
	//display name and score for any player scoring below average
	int i=0;
	while(i=0, i<100, i++)
	{
		if(score[i]<AvgScore)
		{
			cout<<names[i]<<endl;
			cout<<score[i]<<endl;
		}
	}
}


errors are on lines: 20, 21, 22, 23
Last edited on
1
2
3
4
void inputData(string, double, int);
void displayPlayerData(string, double, int);
double calculateAvgScore(double, int);
void displayBelowAvg(double, string, double);


Should be:
1
2
3
4
void inputData(string*, double*, int);
void displayPlayerData(string*, double*, int);
double calculateAvgScore(double*, int);
void displayBelowAvg(double, string*, double*);


So that the declarations actually match the definitions.

Alternatively, you can use the array notation. The code is entirely equivalent:
void inputData(string[], double[], int);
oh my lord.... so simple... thank you T-T
Topic archived. No new replies allowed.