What is the easiest fastest way to see what's in these three arrays. I just want to see what 's in there to make sure my function is working correctly.

#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

const int MAX_ITEMS = 50;
int readData(string studentNames [], int wins [], int losses []);
ifstream infile;


int main()
{

string studentNames[MAX_ITEMS];
int wins[MAX_ITEMS]; 
int losses[MAX_ITEMS];


return 0;	
}

int readData(string studentNames [], int wins [], int losses []) //this function takes data from text file and puts it into an array
{
	infile.open("players.txt");
	
	int count=0;
	while (infile.peek() !=EOF)
	{
		infile >> studentNames[count] >> wins[count] >> losses[count];
		count++;
	}
	infile.close();
	
	return count;
}

Recommended Answers

All 2 Replies

Output the contents in a loop.

just print them

infile >> studentNames[count] >> wins[count] >> losses[count];
cout<< studentNames[count] << " " << wins[count]<< " " << losses[count]<<endl;
count++;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.