I'm a newbie to C++ and figured this would be a good place to ask for guidance.

I need to write a program that reads input from a txt file which contains "grades" in numeric format, I.E. 92, 55, 88 and take those grades and calculate the average.

Now my program uses and input stream and loops through the file contents one character at a time, the values are stored in a CHAR variable called "next".

Basically I'm wondering how I can take a grade which could be 1 to 3 characters and concatenate it, then in turn convert into an INT so I may produce the average with it.

Here is how the txt file is formatted:

lastname firstname grade1 grade2 grade3 etc. etc.

doe john 100 84 82 93 45 55 82
blue joe 28 48 98 84 93 100 89 28 84 99

Since I only take in one CHAR at a time, I need to combine the chars before the next space occurs. I then would need to tally the grades all together into an INT so I may average it out.

Any help would be most appreciated!