Created
March 6, 2019 21:20
-
-
Save leandrobmarinho/847b7498bc03f54c44c8eff6b5dc0f20 to your computer and use it in GitHub Desktop.
Here is a simple program in C++ to verify if a file exists using ifstream.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
bool fexists(const char *filename) | |
{ | |
ifstream ifile(filename); | |
return ifile; | |
} | |
int main () { | |
cout << fexists("filename") << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wrong. "ifile" is of type std::ifstream. The return type bool is incompatible.