My teacher has given me an assignment to parse a text file that contains no more than 25 "Students" the Student object has a Name, and five grades contained within an array.
Now, I've set up the Student file, the Array template file per his instructions and i'm reading in his code as follows. (I've overloaded the << and >> operators as well)
f.open (FileName1, ios_base::in);
if (f.is_open ())
cout << FileName1 << "is open." << endl;
else
{
cout << FileName1 << " was NOT opened." << endl;
f.clear (); //What specifically does this clear?
}
f >> A[0];
cout << A[0];
f.close();
}
Here's a sample of what I'm taking in.
George
75,85,95,100,44
Now I know I forgot to implement something, what exactly I forgot I can't remember! (Smooth; right?)
At the moment what it's doing is taking the first line (The students name) and putting it in the correct place.
It's not taking the integer correctly unless I separate the numbers with an end of line, and I don't expect it to work any other way,but how do I change that default behavior?
Other useless rant/info:
At the moment I'm getting the correct numbers in the integers (I set up a watch and it's right), if I change the text file to make it so that it's one line after each other, they do work, so my overload operators seem to be working fine - I just need to change them to "End" at end of line OR coma's; how would I do that?
Is there a way to see how it works... normally; like the code they used to implement >> and << or... cout and cin? (Or actually, what do I actually need to overload here, what has the default behavior of stopping at end of line, I'm a bit confused)