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
|
bool readData()
{
// Declare local variables
string name, position, team;
name = position = team = "";
int g, att, cmp, yds, lng, td, inte, sck, sckyl;
g = att = cmp = yds = lng = td = inte = sck = sckyl = 0;
float attg, pct, ydsg, rating;
attg = pct = ydsg = rating = 0.0;
// Get file name
string filename = "";
cout << "Enter file name: ";
cin >> filename;
// Open input file
ifstream din;
din.open(filename.c_str());
if (din.fail())
{
cerr << "Could not open file: " << filename << endl;
return false;
}
// Read data
Node *head = NULL;
while (!din.eof())
{
din >> name >> position >> team >> g >> att >> attg >> cmp >> pct >> yds >> ydsg >> lng >> td >> inte >> sck >> sckyl >> rating;
Node *temp = new Node(name, position, team, g, att, attg, cmp, pct, yds, ydsg, lng, td, inte, sck, sckyl, rating);
temp->setNext(head);
head = temp;
}
din.close();
head->print();
return true;
}
|