greatUnited
Name (space) Goals Scored
Josh (space) 1,0,1,-,0,1
George (space) 0,1,0,0,2,0
Nathan (space) 0,0,-,-,1,0
Andy (space) 0,0,1,0,-,-
Eric (space) 1,0,0,-,-,2
Let's think above one is text file. The file name is goalScorers.txt
(space)<< space is not included in the actual text file.I was trying to explain that there is a space between letters in the actual text.
I would like to read that above file. Here is my incomplete following code.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
struct Player
{
string name;
int goals;
int totalGoals ;
};
const int MAX_PLAYERS = 25;
int main(int argc, char *argv[])
{
ifstream scorerFile
char scorerFileName[20] ;
do
{
cout << "Enter file containing data about goal scorers: " ;
cin >> scorerFileName ;
scorerFile.clear() ;
scorerFile.open(scorerFileName) ;
}
while(!scorerFile.good()) ;
That was my half of my code.What i want to read is that i want count the goal score of each player. Can some1 show me the way how to continue with my code? Help need pls....
Regard,
Nay