I would use getline() to read in each line as a std::string. When it comes to those lines which are variable, read the string into a stringstream and use the >> extraction operator to pull out what you need.
That way you can compare each line with "----------" to see when to stop.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 583
Skill Endorsements: 11
Is it reasonable for you to print file as binary file instead of text file?
This way you can read and write entire structure.
But yeah if you need a text file only then you can :
Instead of ------------ you can use some character which you won't use anywhere.
read a line using getline and compare it with above symbol.
If it is not true read thrice and each time separate strings.
Then you can use atoi() and atof()
Vinayak
vinayakgarg
Junior Poster in Training
83 posts since Jan 2010
Reputation Points: 19
Solved Threads: 17
Skill Endorsements: 0
Take a substring (2 characters) of the string you read in using getline, and compare it to "--" (unless you think your professor will put in aberrant lines to test your program. Or if you know the number of dashes ahead of time, compare it with that.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 583
Skill Endorsements: 11