Skip to content

Instantly share code, notes, and snippets.

@Treebug842
Created March 21, 2022 10:05
Show Gist options
  • Save Treebug842/d118b08064f8cee1472879c583cadd58 to your computer and use it in GitHub Desktop.
Save Treebug842/d118b08064f8cee1472879c583cadd58 to your computer and use it in GitHub Desktop.
Simple function to check if a file exists
#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