i'm still having trouble reading this info into the proper struct fields... any help would be appreciated... thanks guys...
the "players.txt" file looks something like this...
34, Marcus, Allby, TE, University of Illinois, New England Patriots
54, Thomas, Shelby, QB, Texas A & M, Chicago Bears
etc...
The idea is to read number 34 into the "number" field of the struct, the last name into the "last name" field of the struct, and so on... here is the code i have so far, with alot of errors on the "getline" part...
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct initInfo
{
int number;
char lastName [20];
char firstName [20];
char position [5];
char college [20];
char nflTeam [30];
};
int main()
{
ifstream playersFile ("players.txt");
initInfo info;
if (playersFile.fail())
{
cout<<"An error occured while trying to open the file."<<endl;
system ("PAUSE");
exit (1);
}
cout<<"File opened"<<endl;
while (!playersFile.eof())
{
getline(playersFile, info.number, ',');
getline(playersFile, info.lastName, ',');
}
playersFile.close();
return 0;
}