#include <sys/stat.h> bool fileExists(const char *filename) { struct stat sb; return stat(filename, &sb) == 0; }This can be used to check if a directory or other non-file item exists too.
Programming Tips - C/C++: See if a file exists
Date: 2025apr7
Language: C/C++
OS: Linux
Q. C/C++: See if a file exists
A.