I am using the following code to parse a file.
std::string line;
std::ifstream infile("C:\\t50_20_1.td");
int num;
int pred;
int succ;
while (std::getline(infile, line))
{
std::istringstream iss(line);
while(iss >> num || !iss.eof()) {
if(iss.fail()) {
iss.clear();
continue;
} else {
std::cout<<num<<std::endl;
}
}
std::cin.ignore();
}
I am trying to print all the numbers in the following file
50
1 35 11 3 13 10 5 11 2 19 1 21 10 23 2 26 3 29 6 35 5 42 10 44 5
2 3 12 8 7 15 12 19 9 24 6 27 13 29 7 32 8 34 6 35 8 37 9 38 12 39 9
3 19 7 4 15 8 2 10 7 15 12 21 11 26 9 36 10
4 35 8 5 13 7 7 10 8 13 13 20 1 21 5 44 1 48 15
But when the program ends I only get one number as output
50