I need to read a text file that contains data of the following type:
John Doe 333222333 01/01/80 M PHY301 2005 Fall A PHY401 2005 Fall B PHY531 2006 Spring A John Doe 333222333 01/01/80 M PHY501 2005 Fall A PHY301 2005 Fall B PHY431 2006 Spring A John Doe 333222333 01/01/80 M PHY301 2005 Fall A PHY401 2005 Fall B PHY531 2006 Spring A
So in other words, the first line will contain whitespace delimited STRINGs. (firstname lastname ssn dob sex) and the lines following it will contain course information (until another student is found) for the student on the first line.
When I only had to deal with one student, I did it like this:
in >> fName >> lName >> ssNum >> dob >> gen; while (in >> cid >> ytt >> stt >> score) .... (store records)
and so on till the end of the file... however I have tried different things for HOURS :( and I cannot figure out a good way to do this.
PS. I am allowed to do the following check: if a line starts with PHY, then it must be a course.
My main problem is that I do not know how to split the getlined string into separate variables and also how to check for PHY in the string.
Thanks for any help you can provide.