Problem reading line and subsequent reading that line.

I am trying to read from a file, each line contains a number of numbers. I want to read one line, and then split that line up so i can set several ints to their values.

I am able to read the line, but it doesn't do the second while.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
std::string line, line2;
	std::ifstream loadFileScore("score.txt");
	
	while (loadFileScore.good()){
		// Reads each line into line.
		getline(loadFileScore, line);
		// Reading that line with stream.
		std::cout << "Line 1: " << line << std::endl;

		std::ifstream scoreLine(line);
		// Should go until reaching end of that line?
		while (scoreLine.good()){
			// Reading one part into line2
			scoreLine >> line2;
			// Printing that part.
			std::cout << line2 << std::endl;
		}
	}
std::ifstream scoreLine(line);It opens file with file name specified by line. Are you sure that it is what you want?

Do you wnat to use stringstream instead: http://en.cppreference.com/w/cpp/io/basic_istringstream/basic_istringstream
Topic archived. No new replies allowed.