How to read selected letters

Hello,
I have a text file in which i need to read only selected letters and substitute them with integers to calculate.
Eg:- In the text file
f2,h1

Here i need to read only the the letters f & h and subtitute them with some integer and add them up.
Somebody pls help.
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... 
Last edited on
Topic archived. No new replies allowed.