So I am taking an intro to programming course, and I have one problem that I haven't been able to solve. This is using the <fstream> library:

Given a text file, I need my program to use the data in it to perform certain operations. I've figured out how to read and echo the file, but I don't know how to use it to perform calculations. Example, I would like to find the average of the numbers in the lines containing 'M' (for male):

Code:
Bailey           M CC 68
Harrison         F CC 71
Grant            M UN 75
How would I make my program get just the numeric input from the lines with an 'M', so that I can find their average?