I'm trying to make a function that will read in the data from a file and store them in an array of structures. I'm not really sure how to do I've tried various things short of just making finding out what the size of the file is as in how big to make the struct.
Code:
struct Node {
string name;
long ID;
int SCORE;
};
Node readStuct()
{
Node *records;
int nSize, i;
myfile2.seekg (0, ios::end);
nSize = myfile2.tellg();
myfile2.seekg (0, ios::beg);
records = new int [nSize];
while(!myfile2.eof())
{
getline(myfile2, records[i].name, '\n');
cout<<records[i].name<<endl;
i++;
}
return records;
}