• Advertisement
Sign in to follow this  

Error proofing reading files with fstream

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm building an IO class based on the one in the Enginuity series but using fstreams instead of the c functions (fopen etc). One thing I would like to do is add in error proofing/checking so that my class will flag up any appropriate problems. I'm trying to decide if its best to this by return types (ie return false or an error code if something goes wrong) or whether to throw an exception. Opinions? The other thing I was wondering is how to check I'm reading the correct data. I can check the length of the file matches what is expected but wondered if there was a better way. I suppose I'm looking for ideas on creating file formats and how to check a particular file i read in is formatted correctly with all the data in the right order. Any references to online articles or books etc would be appreciated. Thanks Jon

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by jonboym
The other thing I was wondering is how to check I'm reading the correct data. I can check the length of the file matches what is expected but wondered if there was a better way. I suppose I'm looking for ideas on creating file formats and how to check a particular file i read in is formatted correctly with all the data in the right order. Any references to online articles or books etc would be appreciated.

Jon


Read whatever you want 10 times, then compare all the read data, chose the data that was read most times. [rolleyes]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement