Should I close a file when it wasn't able to open?
Should I write this:
std::ifstream file(DATA_PATH);
if (!file.good()) //File doesn't exist
{
//do something
}
else //file exists
{
//do something
file.close();
}
Or should I write:
std::ifstream file(DATA_PATH);
if (!file.good()) //File doesn't exist
{
//do something
}
else //file exists
{
//do something
}
file.close();