Reading information from text file

Hello, I need to read some information from a text file. The program I'm working on is like a simple betting program.

What I need to read are;
match_code - team1 - team2 - odd1 - odd0 - odd2

139 Atletico Madrid - Real Madrid 2.85 3.40 2.35

But the spaces between datas are not known. We only know that both team names may contain more than one word and there is one space, exactly one dash and one more space (" – ") between team names.

Also match_code is an int and odds are double values.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
while(getline(input, line))
{
	istringstream ss(line);
	ss >> match_code >> team1;

	string temp;
	while(ss >> temp)
	{
		if(temp != "-")
			team1 += " " + temp;   // to get the second word of team name
		else
		{
			ss >> team2;
			.
			.
			.
		}
	}
}


In that missing part, I need to get the second word of team name if there is one; and the three odds that are odd1 odd0 and odd2. Any help would greatly be appreciated. Thanks in advance!
Last edited on
Maybe look at regular expressions:
http://www.cplusplus.com/reference/regex/

It's tricky stuff, but is a skill worth having.
Topic archived. No new replies allowed.