I'm getting random numbers after running the line convert >> quarter
, I figure I have to clear stringstream out before I run it to convert again, but how would I go about doing that? And could someone explain what's going on during: (I found this as a solution but don't quite understand it)
stringstream convert(tokens[1]);
convert >> quarter;
-
Play parse(string toParse){
vector<string> tokens;
string play = toParse;
string oName, dName;
int x, quarter, minutes, down, yardstogo, startloc, playdesc;
for(int y=0; y<10; y++){
x = toParse.find(",");
tokens.push_back(toParse.substr(0,x));
toParse = toParse.substr(x+1);
}
stringstream convert(tokens[1]);
convert >> quarter;
convert.str(tokens[2]);
convert >> minutes;
convert.str(tokens[6]);
convert >> down;
convert.str(tokens[7]);
convert >> yardstogo;
convert.str(tokens[8]);
convert >> startloc;
playdesc = findPlay(tokens[9]);
Play a(quarter, minutes, tokens[4], tokens[5], down, yardstogo, startloc, playdesc, play);
return a;
}
Thank you.