|
-
March 28th, 2011, 08:26 PM
#1
Having trouble passing array to function.
I am getting all kinds of errors when passing my array to this function. The function is suppose to have the user enter a name and a score and store them in 2 array seperate arrays, one for the names, one for the scores. I believe I have to use pointers but have no idea on how to use them. Here is the code:
#include <iostream>
int InputData(int, char, int);
using namespace std;
void main()
{
char playerName[100][20];
int score[100];
int numPlayers = 0;
int averageScore = 0;
InputData(numPlayers, playerName, score);
}
int InputData(int numPlayers, char playerName[100][20], int score[100])
{
while (numPlayers <= 100)
{
cout << "Enter Player Name (Q to quit): ";
cin.getline(playerName, 100, ‘\n’);
if ((playerName[numPlayers] = 'Q') || (playerName[numPlayers] = 'q'))
return 0;
cout << "Enter score for " << playerName[numPlayers] <<": ";
cin >> score[numPlayers];
numPlayers++;
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|