1 #include "apue.h" 2 #include <fcntl.h> 3 4 5 int main(int argc,char **argv) 6 { 7 if(argc != 2) 8 err_quit("usage:a.out <pathname>"); 9 if(access(argv[1],R_OK) < 0) 10 err_ret("access error for %s",argv[1]); 11 else 12 printf("read access OK\n"); 13 if(open(argv[1],O_RDONLY)<0) 14 err_ret("open error for %s\r\n",argv[1]); 15 else 16 printf("open for reading OK\r\n"); 17 18 exit(0); 19 20 21 return 0; 22 } 23 ~
时间: 2024-11-06 11:32:34