Friday, 13 September 2013

How to parse and store team information from files into classes?

How to parse and store team information from files into classes?

i am stuck on a problem and need some assistance to get over this hump.
I have a few files that contain nba teams and their starters, and i need
to add this information into my program then do a few tasks with them.
I am currently stuck on being able to parse the files.
The files look like this:
Team Name, Point guard, shooting guard, small forward, power forward, center
Chicago Bulls, Derrick Rose, Kyle Korver, Luol Deng, Carlos Boozer, Joakim
Noah
Denver Nuggest, .. etc.
I want to be able to only add the names of the team, point guard, and
small forward, and i'm not sure on how to do that.
What i have so far:
17 ifstream* myIN = new ifstream();
18 myIN->open(filename.c_str());
19
20 string teamName;
21
22 *myIN >> teamName;
23
24 while(!myIN->eof()){
25 TEAM.push_back(teamName);
26 //TODO
27 }
I am looking into using "find()" to find each comma, but i don't know how
to only record the information before and after the first comma, and after
the 3rd comma.
Any sort of guidance would be much appreciated.

No comments:

Post a Comment