
Patrick B. answered 06/14/19
Math and computer tutor/teacher
in unistd.h there is an function called access().
the prototype is access ( char * pathToFile, int accessCode)
you pass the filename and one of the following:
F_OK : the file exists
R_OK : the file can be read
W_OK: the file can be written
X_OK: the file can be executed
you can use the bitwise OR operator to test any or all of them
The return value is zero if the file can be accessed or -1 if it cannot