| Icshorts (3) | |
|
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 // 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; } | |
|
|
|
| AbstractionAnon (517) | |||
Your declaration and implementation don't match.
The function names are not the same. PLEASE USE CODE TAGS (the <> formatting button) when posting code. | |||
|
Last edited on
|
|||
| Icshorts (3) | |
| Thanks! | |
|
|
|
| Branflakes91093 (144) | |
void displayBelowAvg(...);
void displayBelowAverage(...) { }You weren't consistent with the names. | |
|
|
|