1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
//
//
//
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
void loadArrays(int[],int[],int[],int[],int[],int[], const int, string);
int main() {
ofstream statsFileIn;
const int SIZE = 20;
int playerNum[SIZE], atBats[SIZE], hits[SIZE], runs[SIZE], rbis[SIZE], batAvg[SIZE];
string file = "baseballStats.doc";
loadArrays(playerNum, atBats, hits, runs, rbis, batAvg, SIZE, file);
return 0;
}
void loadArrays(int playerNum1[], int atBats1[], int hits1[], int runs1[], int rbis1[], int batAvg1[], const int SIZE1, string file1 )
{
ifstream statsFileIn;
statsFileIn.open(file1);
int i = 0;
int numOfPlayers = 0;
while (statsFileIn >> playerNum1[i] >> atBats1[i] >> hits1[i] >> runs1[i] >> rbis1[i])
{
i = 0;
numOfPlayers = numOfPlayers + 1;
statsFileIn >> playerNum1[i] >> atBats1[i] >> hits1[i] >> runs1[i] >> rbis1[i];
i++;
}
statsFileIn.close();
for (i = 0; i < SIZE1; i++)
{
cout<<playerNum1[i]<< " " <<atBats1[i]<<endl;
}
}
|