Hi all,
I've made some code that reads a text file for a first name, a surname and a rating. The text file has multiple entries in, so here's where I bump into my problem. I want to add all the ratings together, but don't know how as I only seem to know how to get the rating for one entry.
Here's my code:
Could anyone please suggest a way I could add all of the ratings together?Code:#include <iostream.h> #include <fstream.h> int main() { char first[80], second[80], rating[2]; ifstream inFile("junk.txt", ios::in); while (inFile >> first >> second >> rating) cout << first << " " << second << endl; inFile.close(); cin.get(); return 0; }
Thanks very much,
Mike