I have implemented a solution to a problem that needs to be cross-platform and compatible with the standard C ++ library.
bool isdir(const char *string) {
ofstream file(string, ios::out);
return file.fail();
}
However, if the file is actually writable, the program opens an empty file with a name stringin its working directory. How can I prevent this?
source
share