I have a student name, wins, losses. In that order in a txt file.
I'm trying to read it in and them print it out, but i'm not real sure what I'm doing
#include <iostream>
#include <fstream>
using namespace std;
const int MAX_SCORES = 50;
ifstream infile;
void report(int numItems, string name[], int wins[], int losses[]);
int readData(string name[], int wins[], int losses[]);
int main()
{
string name[MAX_SCORES];
int wins[MAX_SCORES];
int losses[MAX_SCORES];
int numItems;
numItems = readData(name, wins, losses);
}
int readData(string name[], int wins[], int losses[])
{
infile.open("players.txt");
int count=0;
while(infile.peek() !=EOF)
{
infile >> name[count];
infile >> wins[count];
infile >> losses[count];
count++;
infile.ignore(1);
}
infile.close();
return count;
}
void report(int numItems, string name[], int wins[], int losses[])
{
for (int i=0; i<numItems; i++)
cout << name[i] << " " << wins[i] << " " << losses[i] << endl;
}