Code:
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
void ReadPlayerInfo(ifstream& myIn, string NameArray[], int idArray[], int& size);
void ReadProcessBatting (ifstream& myIn, const int id [], float batAvg [], int walkArray[],int size);
void ProcessRecord(string batRec, float& batAvg, int& walk);
int SearchPosition(const int idArray[], int id, int size);
void PrintTable(string nameArray[],int idArray[],float averageArray[],int walkArray[],int size);
int FindHigh(float averageArray[], int size);
int FindLow(float averageArray[], int size);
int main()
{
string PlayerRecordsFile;
string PlayerBattingFile;
ifstream myIn;
ifstream myIn2;
cout << "Enter file name that contains player records: ";
cin >> PlayerRecordsFile;
myIn.open(PlayerRecordsFile.c_str());
while (!myIn)
{
cout << "Enter file name that contains player records: ";
cin >> PlayerRecordsFile;
myIn.open(PlayerRecordsFile.c_str());
}
cout << "Enter file name that contains batting data: ";
cin >> PlayerBattingFile;
myIn2.open(PlayerBattingFile.c_str());
while (!myIn2)
{
cout << "Enter file name that contains batting data: ";
cin >> PlayerBattingFile;
myIn2.open(PlayerBattingFile.c_str());
}
return 0;
}
void ReadPlayerInfo(ifstream& myIn, string NameArray[], int idArray[], int& size)
{
string playerName;
int playerNumber;
myIn >> playerName;
NameArray[0] = playerName;
myIn >> playerNumber;
idArray[0] = playerNumber;
}
This is what I have so far. Basically for the first data file which store player records. I need to read in their name and number and store it to two different arrays.
the data file looks like
name number
name number
...
name number
What exactly does my function call inside main need to look like for it?
I thought this but i was dead wrong i guess
Code:
ReadPlayerInfo(ifstream& myIn, string NameArray, int idArray, int& size);