What’s the best way to check if a file exists in C?
Is there a better way than simply trying to open the file? int exists(const char *fname) { FILE *file; if ((file = fopen(fname, “r”))) { fclose(file); return 1; } return 0; } 8 s 8 Look up the access() function, found in unistd.h. You can replace your function with if( access( fname, F_OK ) == … Read more