C++ Give a text file consisting of digits and letters, your task is to find the int-type numbers from the file and calculates their sum. I tried to use
while (!file.eof()) {
file >> x; /// declared x as int
sum += x;
}
but it was an infinite loop. How can I do that? Thank you!