您的位置:首页 >> 编程开发 >> C/C++ >> 正文
C/C++ RSS
 

access函数使用方法+例子

http://www.rdxx.com 05年09月13日 23:27 Blog.ChinaUnix.net 我要投稿

关键词: 方法 , 函数 , Access , CES

access函数是的使用

#include

int access (const char *pathname, int mode)

mode      说明

R_OK      测试读许可权

W_OK     测试写许可权

X_OK      测试执行许可权

F_OK       测试文件是否存在

      1 #include
      2 #include
      3 #include
      4 #include
      5
      6
      7 main(int argc, char *argv[])
      8 {
      9         if(argc != 2)
     10                 printf("usage: a.out \n");
     11         if(access(argv[1], R_OK) < 0)
     12                 printf("access error for %s\n", argv[1]);
     13         else
     14                 printf("read access OK\n");
     15         if(open(argv[1], O_RDONLY) < 0)
     16                 printf("open error for %s\n",argv[1]);
     17         else
     18                 printf("open for reading OK\n");
     19         exit(0);
     20 }


 
 
标签: 方法 , 函数 , Access , CES 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站