In the previous version of C ++ (C ++ 03), open() only accepts const char * for the first parameter instead of std::string . The correct way to call it:
myFile.open(filename.c_str());
In current C ++ (C ++ 11), this code is fine, so see if you can tell your compiler that it supports it.
source share