Sign in to follow this  
Cacks

C++ file I/O

Recommended Posts

Cacks    179
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
dave    2187
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this