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
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void openfile(string winteam[], string loseteam[], int rascores[], int raysize, int count);
int main()
{
string winteam, loseteam;
int rascores, raysize, count;
//Will read from the array
openfile(winteam, loseteam, rascores, raysize, count);
}
void openfile(string winteam[], string loseteam[], int rascores[], int raysize, int count)
{
ifstream input;
input.open ("superbowl.dat"); //opening the file.
if (input.is_open()) //if the file is open
{
for(int i=0; i<raysize; i++)
{
getline(input, winteam[i]);
getline(input, loseteam[i]);
input>>rascores[i];
input.ignore(80, '\n');
}
input.close(); //closing the file
}
else cout << "Unable to open file"; //if the file is not open output
system("PAUSE");
}
|