The access function checks to see whether the file can be accessed in the way specified by the how argument. The how argument either can be the bitwise OR of the flags R_OK, W_OK, X_OK, or the existence test F_OK.
The return value is 0 if the access is permitted, and -1 otherwise.
if the file does not exist, Does the access return -1 too?
I wan to develop a function in which I check the existence of a file. If the following access function did it, what kind of arguments I have to put according to the standard?
if (access("file_example", R_OK | W_OK | X_OK) != -1)
BTW: the file I want to check if exisits by access() function is created by the same application. so it’s created by the same user
Those flags would check if the file is executable, writeable and readable by the process, lots of files won’t be. The flag you’re looking for is F_OK. F_OK tests for the existence of the file and nothing else.
I suggest reading the man page for access. It should be documented there.