J
Juha Nieminen
Consider this:
int main()
{
std::ifstream is("file1");
if(is.good())
{
std::cout << "ok\n";
std::string line;
while(std::getline(is, line));
is.close();
}
is.open("file2");
if(!is.good())
{
std::cout << "failed!\n";
}
}
Assume that both files exist and are normally readable. With gcc the
"failed!" output is not triggered, while with MSVC++ 2005 it is
triggered. (errno points to "no error" in this case, so the file was
clearly opened successfully, but the good() bit was not set.)
I can only assume one of two things. Either
1) good() is *not* the proper way of checking if opening a file
succeeded, or
2) there's a bug in MSVC++ 2005.
Comments?
int main()
{
std::ifstream is("file1");
if(is.good())
{
std::cout << "ok\n";
std::string line;
while(std::getline(is, line));
is.close();
}
is.open("file2");
if(!is.good())
{
std::cout << "failed!\n";
}
}
Assume that both files exist and are normally readable. With gcc the
"failed!" output is not triggered, while with MSVC++ 2005 it is
triggered. (errno points to "no error" in this case, so the file was
clearly opened successfully, but the good() bit was not set.)
I can only assume one of two things. Either
1) good() is *not* the proper way of checking if opening a file
succeeded, or
2) there's a bug in MSVC++ 2005.
Comments?