1,linux
#include <unistd.h> int access(const char *pathname, int mode); //mode填F_OK试试。 返回0表示存在;返回-1表示不存在。
2,window
include <io.h> #include <stdio.h> #include <stdlib.h> void main( void ) { /* Check for existence */ if( (_access( "ACCESS.C", 0 )) != -1 ) { printf( "File ACCESS.C exists " ); /* Check for write permission */ if( (_access( "ACCESS.C", 2 )) != -1 ) printf( "File ACCESS.C has write permission " ); } }