Hi all,
i have created a text file:
Code:
100
200
three hundred
400
my goal is to output at the end : 100, 200, 400. which is worked with the following code:
Code:
while (true) {
if (input >> num) {
cout << num << " - ";
}
else if (input.eof()) {
break;
}
else if (input.fail()) {
input.clear();
input.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
but if i have a text file like this:
Code:
100
200
three 300
400
how should i modify the ignore function, that it does not discard the whole line , but only the word "three", so that i output : 100, 200, 300, 400