Ok here is my new thing for those of you who already looked in here. I am having a problem reading in the scores into array in the records in the array! I have an inputfile:
Code:
joe smith 23
alice west 45
bob MILLS 82
Margaret North 5
*
45 182 210 43 170 301 -1
82 150 97 -220 178 223 300 -1
11 100 105 99 -1
5 97 100 110 123 96 108 130 112 -1
Well I have been able to read in the names and id numbers for the info before the first sentinel (*). Now i have to read in the id number (ex. 45) and see if its a number that corresponds to a person that is in my array already. If it is, i need to read in the rest of the scores until the second sentinel(-1) and then read in the next idnumber. If it is not an idnumber that is in my array already, i need to ignore it. Here is my code and my questions:
Code:
void readidnumbers(ifstream& inputfile, playerrecords league[], int count)
{
int count2;
num;
int scores;
inputfile >> num;
while(!inputfile.eof())
{
for (int i = 0; i < count; i++)
{
if (num == league[i].idnum)
{
inputfile >> scores;
while (scores != SENTINEL2)
{
for(int j = 0; j < MAXGAMES; j++)
inputfile >> scores;
}
}
if (num != league[i].idnum)
inputfile.ignore(100, '\n');
}
}
Am i using the ignore function right? here is my struct:
Code:
struct playerrecords
{
string first, last;
int idnum;
int games[MAXGAMES];
int gamecount;
double gameave;
};
games[MAXGAMES] is where i want to store my scores at...so when i do inputfile >> scores- is it going in there? Also I will need to sort out the invalid scores as well (can only be between 0 and 300). Will that be easy for me once I get the scores read in? Thanks!!!