分类: C/C++

int   access(const   char   *filename,   int   amode); 
amode参数为0时表示检查文件的存在性,如果文件存在,返回0,不存在,返回-1。 
这个函数还可以检查其它文件属性: 
06     检查读写权限 
04     检查读权限 
02     检查写权限 
01     检查执行权限 
00     检查文件的存在性
而这个就算这个文件没有读权限,也可以判断这个文件存在于否
存在返回0,不存在返回-1

C函数
  函数名: access 
  功 能: 确定文件的访问权限 
  用 法: int access(const char *filename, int amode);
[编辑本段]access
  Synopsis
  #include 
  int _access(const char *path,int mode) ;
  Description
  The access function, when used with files, determines whether the specified file exists and can be accessed as specified by the value of mode. When used with directories, _access determines only whether the specified directory exists; since under Windows all directories have read and write access.
  The mode argument can be one of :
  00 Existence only
  02 Write permission
  04 Read permission
  06 Read and write permission 
  Returns
  Zero if the file has the given mode, -1 if an error occurs.
  Portability :
  Windows. Under Unix a similar function exists too.
  Note that lcc-win32 accepts both _access (Microsoft convention) and access.
  程序例: 
  

#include <stdio.h>
  #include <io.h>
  int file_exists(char *filename);
  int main(void)
  {
  printf("Does NOTEXIST.FIL exist: %s\n",
  file_exists("NOTEXISTS.FIL") ? "YES" : "NO");
  return ;
  }
  int file_exists(char *filename)
  {
  return (access(filename, ) == );
  }

最新文章

  1. nodejs操作mongodb数据库封装DB类
  2. 【转】C# 使用消息队列,包括远程访问
  3. 机器学习公开课笔记(8):k-means聚类和PCA降维
  4. sql server还原数据库文件(.bak)常见问题解决办法笔记
  5. codeforces 677C C. Vanya and Label(组合数学+快速幂)
  6. CSS变量variable
  7. springboot+shiro+redis项目整合
  8. 20165321 测试-3-ch02
  9. HTML/CSS基础知识(三)
  10. .net amr格式文件转换成mp3格式文件的方法
  11. 20135316Linux内核学习笔记第八周
  12. Faster RCNN代码理解(Python)
  13. UFPS入门: Unity FPS 教程
  14. 丑闻第三季 /全集Scandal迅雷下载
  15. ubuntu for win10 里运行net core
  16. python startswith() 函数
  17. 【树】Lowest Common Ancestor of a Binary Tree(递归)
  18. 【SSH网上商城项目实战20】在线支付平台的介绍
  19. hdu_1009 贪心
  20. ASP .NET core 入门基础内容备份

热门文章

  1. python模块介绍二。
  2. Xcode 修改工程名以及注意事项
  3. 转发;Dota英文名
  4. js-FCC算法Smallest Common Multiple。找出两个参数和它们之间的连续数字的最小公倍数。
  5. wpf数据绑定
  6. 根据xsd生成C#类
  7. UOJ263 【NOIP2016】组合数问题
  8. NAT功能的研究
  9. C#制作验证码
  10. centos搭建https协议的tomcat和apache服务器以及nginx服务器,mysql php