///Can someone tell me why I am having an issue calling my functions?!?!?!

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

struct Players 
{
    string name; 
    int numPlayer; //Number of the Player
    int numPoints; //Point's scored by Player

};

const int SIZE = 50;
const int MAXPLAYERS =3;

typedef struct  Players Roster[12];
int total;
int maxgoals = 0; 


void Greeting ();
void TotalPoints (Roster &Players);
void HighestScore (Roster &Players);
void DisplayAll (Roster &Players);



int main () 
{
    Roster SoccerPlayers;

    Greeting();
    for (int index=0; index< 2; index++)  // put this in a function
    {
        cout << "Player's Name:";
        getline(cin, SoccerPlayers[index].name);

        do
        {
            cout << "Uniform Number:";
            cin >> (SoccerPlayers[index].numPlayer);
            if (SoccerPlayers[index].numPlayer<=0)
                cout << "Invalid entry, Please re-enter:" << endl;
        }while (SoccerPlayers[index].numPlayer<=0);

        do
        {
            cout << "Points Scored:";
            (cin >> SoccerPlayers[index].numPoints).get();
            if (SoccerPlayers[index].numPoints<=0)
                cout << "Invalid entry, Please re-enter:" << endl;
        }while (SoccerPlayers[index].numPoints<=0);


    }


    DisplayAll(Players);
    TotalPoints(Players);
    HighestScore(Players);






    return 0;
        }

void Greeting ()
{
    cout << "___________________________________________________" << endl;
    cout << "Welcome to the Soccer Team Data Analyzer" << endl;
    cout << "You will now be asked to enter the name" << endl;
    cout << "uniform number, and points earned for each player." << endl;
    cout << "___________________________________________________" << endl;

}




void DisplayAll (Roster &SoccerPlayers)
{
    cout << "Players Score Summary" << endl << endl;
    cout << "_________________________" <<endl;
    cout << "Name               Number                Score" << endl;
    cout << "_________________________" << endl;
    for (int index=0; index< MAXPLAYERS; index++)
    {
    cout << setw(20) <<left << SoccerPlayers[index].name;
    cout << setw(15) <<left << SoccerPlayers[index].numPlayer;
    cout << SoccerPlayers[index].numPoints;
    }



}



void TotalPoints (Roster &SoccerPlayers)
{
    int TotalScore = 0;
    for (int index = 0; index < 2; index++)
    {

        TotalScore += (SoccerPlayers[index].numPoints);


    }
}


void HighestScore (Roster &SoccerPlayers)
{


    int max = SoccerPlayers[0].numPoints;
    int maxIndex = 0;
    for (int index = 0; index < 2; index++)
    { 
        if (SoccerPlayers[index].numPoints > max) 
        {
            max = SoccerPlayers[index].numPoints;
            maxIndex = index;
        }
    }

}

when I call the three functions DisplayAll(Players), TotalPoints(Players), and HighestScore(Players) in the main i get "error: expected primary-expression before ‘)’ token"

main.cpp: In function ‘int main()’:
main.cpp:59: error: expected primary-expression before ‘)’ token
main.cpp:60: error: expected primary-expression before ‘)’ token
main.cpp:61: error: expected primary-expression before ‘)’ token

Try changing

   DisplayAll(Players);
   TotalPoints(Players);
   HighestScore(Players);

To

   DisplayAll(SoccerPlayers);
   TotalPoints(SoccerPlayers);
   HighestScore(SoccerPlayers);

DisplayAll(Players);

lines 59-61: If that is a prototype then it should be DisplayAll(Players&)

Edited 4 Years Ago by Ancient Dragon

This article has been dead for over six months. Start a new discussion instead.