To check if a file exists in C you can use the follwing snippet.

Sample C

#include <unistd.h>  
  
int fileExists(const char *filename) {  
    return !access(filename, F_OK);  
}  

One thought on “How to check if a file exists in C”

Leave a Reply