I have a simple data file that I want to load, in a C++ program. For weird reasons, it doesn't work:
- I tried it on Windows assuming the file was in the same directory: failed.
- I tried it on Windows by moving the file in C:\ directory: worked.
- I tried it on Linux putting the file in the same directory: failed.
The snippet:
void World::loadMap(string inFileName) {
ifstream file(inFileName.c_str(), ios::in);
if (file) {
}
else
{
cout<<"Error when loading the file \n";
exit(-1);
}
}
I call the loadMap method like this:
World::Instance()->loadMap("Map.dat");
(World is a singleton class).
How can I find the exact error, by using try-catch or anything else?