I want to check if a file exists and tried to use the following function
#include
bool DoesFileExist(const std::string& filename) {
std::ifstream ifile(filename.c_str());
return (bool)ifile;
}
However, it does not seem to work properly, because instead of checking the existence a file is created! What's the problem here?
Note that I'm forced to use C++98 standard and cannot use #include
or #include
as suggested in the accepted answer here.
No comments:
Post a Comment