Help With Functions

I am getting the following errors:

Error 1 error LNK2019: unresolved external symbol "double __cdecl CalculateAverageScore(int * const,int)" (?CalculateAverageScore@@YANQAHH@Z) referenced in function _main c:\Users\Jennifer\documents\visual studio 2010\Projects\Nobles_J_ilab5_A\Nobles_J_ilab5_A\videoGamePlayerProgram.obj

Error 2 error LNK2019: unresolved external symbol "void __cdecl DisplayPlayerData(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * const,int * const,int)" (?DisplayPlayerData@@YAXQAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAHH@Z) referenced in function _main c:\Users\Jennifer\documents\visual studio 2010\Projects\Nobles_J_ilab5_A\Nobles_J_ilab5_A\videoGamePlayerProgram.obj

Error 3 error LNK2019: unresolved external symbol "void __cdecl InputData(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * const,int * const,int &)" (?InputData@@YAXQAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAHAAH@Z) referenced in function _main c:\Users\Jennifer\documents\visual studio 2010\Projects\Nobles_J_ilab5_A\Nobles_J_ilab5_A\videoGamePlayerProgram.obj


Here's my code:
// ----------------------------------------------------------------------
// Programming Assignment: Ilab05A
// Developer: Jennifer Nobles
// Date Written: 2/6/2013
// Purpose: Video Game Player Program
// ----------------------------------------------------------------------

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
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
using namespace std;
 
const int ARRAY_SIZE = 100; // Declare Array size

// Prototypes
void InputData(string [],int [], int &);
void DisplayPlayerData(string [], int [], int);
double CalculateAverageScore(int [], int );
void DisplayBelowAverage(string [],int [], int, double);

int main() // Main 
{
    string playerName[ARRAY_SIZE];
    int score[ARRAY_SIZE];
    int numPlayers = 0;
    double averageScore = 0;
 
    cout << fixed << showpoint << setprecision(2);
    InputData(playerName, score, numPlayers);
    DisplayPlayerData(playerName, score, numPlayers);
    CalculateAverageScore(score, numPlayers);
    DisplayBelowAverage(playerName, score, numPlayers, averageScore);
     
             system("PAUSE");
             return(0);
}

void inputData(string playerName[], int score[], int numPlayers) // inputData function
{
	while(numPlayers < ARRAY_SIZE)

{
       cout << "Enter player's name (Q to quit):  ";
        getline(cin, playerName[numPlayers], '\n');
        cout << endl;
        if ((playerName[numPlayers] == "Q") || (playerName[numPlayers] == "q"))
            break;
        cout << "Enter " << playerName[numPlayers] << "'s score:  ";
        cin >> score[numPlayers];
        cout << endl;
        cin.ignore();
        numPlayers++;
    }
}


void DisplayPlayerData(string playerName[], const int score[], int numPlayers)
{
    cout << setw(10) << left << "\n Name"
        << setw(5) << right << "Score" << endl;
    for (int i = 0; i < numPlayers; i++)
    { 
        cout << setw(10) << left << playerName[numPlayers] 
        << setw(5) << right << score[numPlayers] << endl;
    }
}

     
    double calculateAverageScore(int score[], int numPlayers)
{
    int i;
    double averageScore = 0, totalScore;
    for (i = 0, totalScore = 0; i < numPlayers; i++)
    {
        totalScore += score[i];
    }
    averageScore = totalScore/i;
    cout << fixed << showpoint << setprecision(2);
    cout << averageScore << endl << endl;
    return averageScore;
}
void DisplayBelowAverage(string playerName[],int score[], int numPlayers, double averageScore)
{
    cout << "Players who scored below average\n";
    cout << setw (10) << left << "Name"
        << setw(5) << right << "Score" << endl;
    for (int i = 0; i < numPlayers; i++)
        if(score[i] < averageScore)
            cout << setw (10) << left << playerName[i]
        << setw(5) << right << score[i] << endl;
}




I have looked at the prototypes, function calls in main, and at the headers and cannot find the issue. Can someone point me in the right direction?


Last edited on
The prototypes don't match.
What do you mean they don't match? Don't match what? :)
Look at the prototypes. You aren't declaring the types of variables that you are taking as parameters.
closed account (3qX21hU5)
Please use codetags when posting code to the forums. You will probably get more replies since it is much easier to read code with codetags. All you need to do it highlight all the code you pasted in and then click the <> button off to the right when replying.
I put string and int as parameters. I don't know what else I am supposed to put.
Ok Zereo...didn't know how to do that :) ...fixed now
Case sensitive
1
2
double CalculateAverageScore(int [], int ); //declaration
double calculateAverageScore(int score[], int numPlayers) //definition 


Changing the type
1
2
void DisplayPlayerData(string [], int [], int);
void DisplayPlayerData(string playerName[], const int score[], int numPlayers)
Topic archived. No new replies allowed.