Created
March 21, 2022 10:05
-
-
Save Treebug842/d118b08064f8cee1472879c583cadd58 to your computer and use it in GitHub Desktop.
Simple function to check if a file exists
This file contains hidden or 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> | |
#include <string> | |
bool doesFileExist(const char* path){ | |
std::ifstream file(path); | |
if(!file.is_open()){ | |
return false; | |
} | |
return true; | |
} | |
int main() { | |
std::cout << doesFileExist("/books/dictionary.pdf") << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment