ERROR CODE

I am confused to what I'm doing wrong with this code. I keep getting this error message.
1>------ Build started: Project: LAB5A, Configuration: Debug Win32 ------
1> MAIN.cpp
1>MAIN.obj : error LNK2019: unresolved external symbol "void __cdecl displayBelowAvg(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * const,int * const,double &,int &,int &)" (?displayBelowAvg@@YAXQAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAHAANAAH3@Z) referenced in function _main
1>C:\Users\610pawn\Documents\Visual Studio 2010\Projects\LAB5A\Debug\LAB5A.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


but my code is

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
// Video Game Player Program
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>

using namespace std;

// Prototypes

int inputData( string[], int[], int &) ;
void displayPlayerData( string[], int[], int&);
double calcAvgScore(int[], int&) ;
void displayBelowAvg(string[], int[], double&, int&, int&) ; 
const int SIZE = 100;

int main()
{
	// array of strings
	string playerName[SIZE] ;
	// array of ints
	int score [SIZE] ;
    int numPlayers = 0;
	int scores =0;
	double avgScore =0;
	// call input data function
	inputData(playerName, score,numPlayers);
	// call display Player function
	displayPlayerData(playerName, score,numPlayers);
	// call calculate average score function
	calcAvgScore(score, numPlayers);
	// call display below average function
	displayBelowAvg( playerName, score, avgScore,scores, numPlayers);

	return 0;
	system("pause") ;

}

int inputData( string playersName[], int scores[], int & numPlayers) 
{

	string playerName[SIZE];
	
	int score[SIZE];
	string toupper =" Q";
	while(numPlayers < SIZE && playerName[numPlayers] != ("Q"))
	{
		playerName[numPlayers] = numPlayers * numPlayers;
		cout << "Please enter player name:" << endl;
		cin >> playerName[numPlayers];
		if ( playerName[numPlayers] == "Q")
			cout << " The Q was entered to quit!" << endl;
		if (playerName[numPlayers] != "Q")
			cout << "Please enter player score:" << endl;
		
		cin.ignore();
		numPlayers++;
		for( int scores=0; scores < SIZE; scores ++) 
		{score[scores] = scores * scores;}
		    
		return numPlayers;

	}

	return 0;

}
void displayPlayerData( string playerName[], int score[], int& numPlayers)
{

	for( numPlayers = 0; numPlayers < SIZE; numPlayers++);
		cout << " The players are:" << playerName[numPlayers] << " ";
	
	
		for (int scores = 0;scores < SIZE; scores ++)
			cout << " The scores are:" << score[scores] << " ";


}
 double calcAvgScore(int score[], int& numPlayers) 
 {
	 double total =0;
	 int scores=0;
	 double avgScore =0;
	 
	 for (int scores =0; scores < SIZE; scores ++)
	 { total += score[scores] ;}
	 avgScore= total / scores;

	 cout << " The average score is:" << avgScore << endl;
	 cout << setprecision(2) << fixed;
	 return avgScore;
}
 void displayBelowAverage(string playerName[], int score[], double&avgScore, int&scores, int& numPlayers)
 {

	 if(score[scores] < avgScore)
		 cout << " The players that are below average are:" << playerName[numPlayers] << score[scores] << endl; 
 
 }

Last edited on
Your declaration and implementation don't match.
1
2
3
 
void displayBelowAvg(string[], int[], double&, int&, int&) ; 
void displayBelowAverage(string playerName[], int score[], double&avgScore, int&scores, int& numPlayers)

The function names are not the same.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
Last edited on
Thanks!
void displayBelowAvg(...); void displayBelowAverage(...) { }

You weren't consistent with the names.
Topic archived. No new replies allowed.