Archived

This topic is now archived and is closed to further replies.

RegularKid

HELP...

Recommended Posts

Oluseyi    2116

fstream file;
file.open(filename, ios::in|ios::nocreate);
if(file.fail())
{
// we either couldn''t open the file
// or couldn''t create it
return -1;
}
// use file here

You could also use file.good() to check if the open was successful (which means the file could be opened and thus exists) and close() it right after that.



I wanna work for Microsoft!

Share this post


Link to post
Share on other sites
Gladiator    127
  

ifstream fileInput("filename.ext");

if (fileInput)
{

// successful openning


}
else
{

// error (file not there or there was an error opening it


}



Hope this helps...

Share this post


Link to post
Share on other sites