1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
//#include <sstream>>
//fstream cfs("roster.csv");
//holder is a string, declared globally, to be a temporary holder for the data being read in
void readIntoStruct()
{
getline(cfs, holder, ',');
getline(cfs, holder, ',');
int i = 0;
while(!(cfs.eof()))
{
getline(cfs, holder, ',');
getline(cfs, holder, ',');
rosterA[i].name = holder; //I assume we can do this because they are both strings
getline(cfs, holder, ',');
stringstream(holder)>>rosterA[i].homeruns; //we have to use stringstream
getline(cfs, holder, ','); //because holder and .homeruns are
stringstream(holder)>>rosterA[i].strikeouts; //different data types?
getline(cfs, holder, ','); //(i'm unsure if i interpreted this
stringstream(holder)>>rosterA[i].singles; //correctly)
getline(cfs, holder, ',');
stringstream(holder)>>rosterA[i].doubles;
getline(cfs, holder, ',');
stringstream(holder)>>rosterA[i].triples;
getline(cfs, holder, ',');
stringstream(holder)>>rosterA[i].atbats;
getline(cfs, holder, ',');
stringstream(holder)>>rosterA[i].onbaseavg;
getline(cfs, holder, ',');
stringstream(holder)>>rosterA[i].batavg;
i++;
if(i>=9)
{
break;
}
}
}
//this is for teamA only, ive replicated this code for teamB as well.
|