you can use the .get() member function for a file so that you can compare
individual characters e.g.
1 2 3 4 5 6 7 8 9 10 11 12 13
char ch;
ifstream file;
file.open( "sample.txt");
while (!file.eof()) {
file.get(ch);
if (ch == 'h' || ch == 'f') {
/* convert character to integer
and store it.... */
}
}
// do what ever arithmetic with integers...