zoukankan      html  css  js  c++  java
  • 程序4-2 access函数实例

     1 //http://blog.chinaunix.net/uid-24549279-id-71355.html
     2 /*
     3  ============================================================================
     4  Name        : test.c
     5  Author      : blank
     6  Version     :
     7  Copyright   : Your copyright notice
     8  Description : 程序4-2 access函数实例
     9  ============================================================================
    10 */
    11 
    12 #include <stdio.h>
    13 #include <fcntl.h>
    14 #include <sys/stat.h>
    15 #include "ourhdr.h"
    16 
    17 #define BUFFSIZE 4096
    18 
    19 int main(int argc, char *argv[])
    20 {
    21     if (argc != 2){
    22         err_quit("usage: ./test <filename>
    ");
    23     }
    24 
    25     if (access(argv[1], R_OK) < 0){
    26         err_ret("access error for %s", argv[1]);
    27     }else{
    28         printf("read access OK
    ");
    29     }
    30 
    31     if (open(argv[1], O_RDONLY) < 0){
    32         err_ret("open error for %s", argv[1]);
    33     }else{
    34         printf("open for read OK
    ");
    35     }
    36 
    37     exit(0);
    38 }
  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    iOS开发系列--IOS程序开发概览
    iOS开发系列—Objective-C之Foundation框架
  • 原文地址:https://www.cnblogs.com/blankqdb/p/3693902.html
Copyright © 2011-2022 走看看