For starters, why don't you consider writing an overload for operator>>. I suspect that the stream is invalid after you check it but before you have read in a whole object. The half filled element would then be the 11th entry. Maybe your file has a blank line at the end...
Code:
// helper function
void get(istream& s, std::string& str)
{
s>>str;
// check for a failed stream in the middle of reading a
// record: Maybe you can throw an exception or something
// here that you can catch in some outer while loop
if ( s.fail() ) // throw Some_Exception();
}
istream& operator>>(istream& s, DATA& d)
{
get(s,d.idNumber);
get(s,d.LastName);
get(s, d.FirstName);
get(s, d.Major);
get(s, d.Class);
return s;
}
int main()
{
// much code excluded...
DATA* data = new DATA();
try {
while(sin) {
sin>> *data;
InsertTail(data);
count++;
}
}
catch(...) {
// catch your exception here
}
return 0;
}