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

Output the contents in a loop.

Jump to Post

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.