check if a file is present in c code example
Example 1: c check if file exists
if( access( fname, F_OK ) == 0 ) {
// file exists
} else {
// file doesn't exist
}
Example 2: c check if file was created
int canCreateFile(char* path)
{
FILE* file = fopen(path, "w");
if(file)
{
fclose(file);
return 1;
}
return 0;
}