\* C file handling program to check a specified file has read, write, and execute permission or not *\
# include < stdio.h >
# include < unistd.h >
int main( )
{
int ret = 0 ;
char filename[20] ;
printf("\n Enter the filename to be opened : ") ;
scanf("%s", filename ) ;
ret = access( filename, R_OK ) ;
if (ret != -1)
printf(" %s has read access", filename ) ;
else
printf(" %s has not read access", filename ) ;
ret = access( filename, W_OK ) ;
if ( ret != -1 )
printf("\n %s has write access", filename) ;
else
printf("\n %s has not write access", filename) ;
ret = access(filename, X_OK) ;
if (ret != -1)
printf( "\n %s has execute access", filename ) ;
else
printf( "\n %s has not execute access", filename ) ;
printf("\n") ;
return 0 ;
}