Skipping blank lines using getline

So, I'm writing a class named Pitcher that gets a name and stats from a text file. The text file is formatted with a bunch of new line characters followed by the name on one line and the stats on the next line. Sort of like this:


FirstName LastName
12 5 10 6 4 9

I know that the getline() function will read the line until the newline character is reached. My question is how do I read the name using getline into a member, followed by the remaining stats without storing the newline characters? So far, the class assigns the stats into name instead of the actual name and the stats are assigned default values.

1
2
3
4
5
6
7
8
  void Pitcher::loadData(istream &in) {
	getline(in, name);
	while (name == "") {
		getline(in, name);
	}
	getline(in, name);
	in >> wins >> saves >> inningsPitched >> earnedRuns >> hits >> walks;
}
Could you just remove the extra getline calls?

1
2
3
4
5
6
7
8
  void Pitcher::loadData(istream &in) {
	//getline(in, name);
	while (name == "") {
		getline(in, name);
	}
	//getline(in, name);
	in >> wins >> saves >> inningsPitched >> earnedRuns >> hits >> walks;
}
I figured it out, the third getline was the problem. Thanks though!
Topic archived. No new replies allowed.