String Array into Function

I'm trying to call a const string array into a function but I keep getting an error, I can't seem to figure out the correct way to call the array so I can use the actual names that are entered to display the two d array instead of just having "Players 1, 2, and 3 ".

const int PLAYERS = 3;
const int DAYS = 7;

void printDisp(const int[][DAYS], const string[]);

int main()
{
//use decimal output, to two decimal places and show decimal
cout << fixed << setprecision(2) << showpoint;

string name;
name[PLAYERS] = {};

for (int i = 0; i < PLAYERS; i++)
{
cout << "Please enter the name of player " << i + 1 << ": ";
getline(cin, name);
}

int scores[PLAYERS] [DAYS] = {{72, 71, 70, 71, 69, 67, 75},
{69, 72, 64, 72, 74, 66, 71},
{68, 74, 73, 67, 72, 70, 65}};

printDisp(scores, name);


system("pause");
return 0;

}//end of main;

void printDisp(const int scores[][DAYS], const string name[])
{
cout << "Name" << "\tDay 1" << "\tDay 2" << "\tDay 3" << "\tDay 4" << "\tDay 5" << "\tDay 6" << "\tDay 7" << endl;
cout << "----" << "\t-----" << "\t-----" << "\t-----" << "\t-----" << "\t-----" << "\t-----" << "\t-----" << endl;

for (int a = 0; a < PLAYERS; a++)
{
cout << "Player " << a+1 << " ";
for (int b = 0; b < DAYS; b++)
{
cout << scores[a][b] << " \t";

}
cout << endl;

}

}
Do you know that a std::string instance is not an array?

Your print function should be more like:

void printDisp(const int scores[][DAYS], const std::string& name);
Registered users can post here. Sign in or register to post.