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
|
#include <iostream>
#include <fstream>
using namespace std;
ifstream din;
void openFile()
{
string filename;
cout << "Enter name of file with QB statistics" << endl;
cin >> filename;
din.open(filename.c_str());
if (din.fail())
{
cout << "Failed to open file. Aborting program" << endl;
return;
}
}
int main()
{
openFile();
int count = 0;
int games, attempts, completions, yards, lng, tds, ints, sacks, sackYL;
float attperg, compct, yrdsgame, rating;
string first_name, last_name, team, pos;
din >> first_name >> last_name >> pos >> games >> attempts >> attperg >> completions >> compct >> yards >> yrdsgame >> lng >> tds >> ints >> sacks >> sackYL >> rating;
while (count < 5)
{
cout << first_name << " " << last_name << " " << pos << " " << games << " " << attempts << " " << attperg << " " << completions << " " << compct << " " << yards << " " << yrdsgame << " " << lng << " " << tds << " " << ints << " " << sacks << " " << sackYL << " " << rating << endl;
din >> first_name >> last_name >> pos >> games >> attempts >> attperg >> completions >> compct >> yards >> yrdsgame >> lng >> tds >> ints >> sacks >> sackYL >> rating;
count++;
}
din.close();
return 0;
}
|