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;
}

What is happening, what problems are occurring? As it is now, the program won't actually do anything, as you never call report() .

Good catch. Didn't notice that.

#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);
report(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;
}

PlayerRankings.cpp: In function 'int main()':

PlayerRankings.cpp:21: error: invalid conversion from 'std::string*' to 'int'

PlayerRankings.cpp:21: error: cannot convert 'int*' to 'std::string*' for argument '2' to 'void report(int, std::string*, int*, int*)'

This question has already been answered. Start a new discussion instead.