Function name : access
Header file : <io.h>
Function prototype : int access(const char *file,int auth);
Function : Determine file access permissions
Parameters : const char *file is the file name, int auth value of 0 indicates whether the test file exists, and value of 2 indicates whether the test file is writable.
Return value : If the test result is allowed, return 0, otherwise return -1
Program example : Determine whether the specified file exists and output a prompt
#include<stdio.h>#include<io.h>intmain(void){printf(DoseNOTEXISTS.FILexits?n);printf(%s,access(NOTEXISTS.FIL,0)==0?YES:NO) ;putchar('n');return0;}
Running results
DoesNOTEXIST.FILexist?NO