c语言文件操作函数_access函数怎么用

C语言_access函数怎么用_百度知道
C语言_access函数怎么用
提问者采纳
please check it in MSDN_access, _waccessDetermine file-access permission.int _access( const char *path, int mode );/* ACCESS.C: This example uses _access to check the* file named &ACCESS.C& to see if it exists and if* writing is allowed.*/#include &io.h&#include &stdio.h&#include &stdlib.h&void main( void ){/* Check for existence */if( (_access( &ACCESS.C&, 0 )) != -1 ){printf( &File ACCESS.C exists\n& );/* Check for write permission */if( (_access( &ACCESS.C&, 2 )) != -1 )printf( &File ACCESS.C has write permission\n& );}}OutputFile ACCESS.C existsFile ACCESS.C has write permission
提问者评价
太给力了,你的回答完美解决了我的问题!
其他类似问题
access函数的相关知识
按默认排序
其他1条回答
index.html
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁C语言用函数access判断文件是否存在 - 程序员部落
所在位置: >
> C语言用函数access判断文件是否存在
C语言用函数access判断文件是否存在
用函数access,头文件是io.h,原型: int access(const char *filename, int amode); amode参数为0时表示检查文件的存在性,如果文件存在,返回0,不存在,返回-1。 这个函数还可以检查其它文件属性: 06 检查读写权限 04 检查读权限 02 检查写权限 01 检查
用函数access,头文件是io.h,原型:
& int&& access(const&& char&& *filename,&& int&& amode);
amode参数为0时表示检查文件的存在性,如果文件存在,返回0,不存在,返回-1。
这个函数还可以检查其它文件属性:
06&&&& 检查读写权限
04&&&& 检查读权限
02&&&& 检查写权限
01&&&& 检查执行权限
00&&&& 检查文件的存在性
在UNIX和VC下实验成功。
好处是 fopen(..,&r&)不好,当无读权限时一不行了。
而这个就算这个文件没有读权限,也可以判断这个文件存在于否
存在返回0,不存在返回-1
#include&&stdio.h&&int&main()&{&&&&&&&&printf&(&%d&,access(&111&,0));&
(责任编辑:itword)
const用法主要是防止定义的对象再次被修改,定义对象变量时要初始化变量 下面我就介绍一下几种常见的用法 1.用于定义常量变量,这样这个变量在后面就不可以再被修改 const int Val = 10; //Val = 20; //错误,不可被修改 2. 保护传参时参数不被修改,如果使用引...
群1【】 Copyright & 2010-,All Rights Reserved.苏ICP备号
程序员部落 版权所有&&百度文库-信息提示
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
信息提示对不起,该文档已被删除,无法查看
4秒后,自动返回首页C语言_access函数怎么用_百度知道
C语言_access函数怎么用
提问者采纳
please check it in MSDN_access, _waccessDetermine file-access permission.int _access( const char *path, int mode );/* ACCESS.C: This example uses _access to check the* file named &ACCESS.C& to see if it exists and if* writing is allowed.*/#include &io.h&#include &stdio.h&#include &stdlib.h&void main( void ){/* Check for existence */if( (_access( &ACCESS.C&, 0 )) != -1 ){printf( &File ACCESS.C exists\n& );/* Check for write permission */if( (_access( &ACCESS.C&, 2 )) != -1 )printf( &File ACCESS.C has write permission\n& );}}OutputFile ACCESS.C existsFile ACCESS.C has write permission
提问者评价
太给力了,你的回答完美地解决了我的问题,非常感谢!
其他类似问题
access函数的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 c语言time函数 的文章

 

随机推荐