Jump to content
  • Advertisement
Sign in to follow this  
Cacks

C++ file I/O

This topic is 4499 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 guys, I have created methods for saving and loading my objects to and from disk. They work fine. I'm using VC++ .Net 2003, but I'm using std ifstream & ofstream. I'm wondering what kinds of exceptions can this throw? I'm especially interested in how I would find if the file intended to be loaded does not exist? How would I deal with this error. Thanks for any help given!

Share this post


Link to post
Share on other sites
Advertisement
Hey bud,

What i would do here is simply try and open the file as you prolly already are, but then immediately check the whether it is open or not, like this:

if ( myFile.is_open() )
{
// blah
}


I'm not particularly expereince with C++ files but i believe there is no need to worry about exceptions here. If it isn't open then it isn't open.

Hope that helps,

Dave

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!