MyException - 我的异常网
当前位置:我的异常网» C语言 » fopen有关问题

fopen有关问题(2)

www.MyException.Cn  网友分享于:2013-06-15  浏览:31次

to indicate the error.

ERRORS
The fopen() function shall fail if:

EACCES Search permission is denied on a component of the path prefix, or the file
exists and the permissions specified by mode are denied, or the file does not
exist and write permission is denied for the parent directory of the file to
be created.

EINTR A signal was caught during fopen().

EISDIR The named file is a directory and mode requires write access.

ELOOP A loop exists in symbolic links encountered during resolution of the path
argument.

EMFILE {OPEN_MAX} file descriptors are currently open in the calling process.

ENAMETOOLONG

The length of the filename argument exceeds {PATH_MAX} or a pathname compo-
nent is longer than {NAME_MAX}.

ENFILE The maximum allowable number of files is currently open in the system.

ENOENT A component of filename does not name an existing file or filename is an
empty string.

ENOSPC The directory or file system that would contain the new file cannot be
expanded, the file does not exist, and the file was to be created.

ENOTDIR
A component of the path prefix is not a directory.

ENXIO The named file is a character special or block special file, and the device
associated with this special file does not exist.

EOVERFLOW
The named file is a regular file and the size of the file cannot be repre-
sented correctly in an object of type off_t.

EROFS The named file resides on a read-only file system and mode requires write
access.


The fopen() function may fail if:

EINVAL The value of the mode argument is not valid.

ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during resolution of
the path argument.

EMFILE {FOPEN_MAX} streams are currently open in the calling process.

EMFILE {STREAM_MAX} streams are currently open in the calling process.

ENAMETOOLONG

Pathname resolution of a symbolic link produced an intermediate result whose
length exceeds {PATH_MAX}.

ENOMEM Insufficient storage space is available.

ETXTBSY
The file is a pure procedure (shared text) file that is being executed and
mode requires write access.


The following sections are informative.

EXAMPLES
Opening a File
The following example tries to open the file named file for reading. The fopen()
function returns a file pointer that is used in subsequent fgets() and fclose()
calls. If the program cannot open the file, it just ignores it.


#include <stdio.h>
...
FILE *fp;
...
void rgrep(const char *file)
{
...
if ((fp = fopen(file, "r")) == NULL)
return;
...
}

APPLICATION USAGE
None.

RATIONALE
None.

FUTURE DIRECTIONS
None.

SEE ALSO
fclose() , fdopen() , freopen() , the Base Definitions volume of
IEEE Std 1003.1-2001, <stdio.h>

COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std
1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating Sys-
tem Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C)

文章评论

10个帮程序员减压放松的网站
10个帮程序员减压放松的网站
如何区分一个程序员是“老手“还是“新手“?
如何区分一个程序员是“老手“还是“新手“?
什么才是优秀的用户界面设计
什么才是优秀的用户界面设计
程序员周末都喜欢做什么?
程序员周末都喜欢做什么?
老美怎么看待阿里赴美上市
老美怎么看待阿里赴美上市
不懂技术不要对懂技术的人说这很容易实现
不懂技术不要对懂技术的人说这很容易实现
“懒”出效率是程序员的美德
“懒”出效率是程序员的美德
那些争议最大的编程观点
那些争议最大的编程观点
聊聊HTTPS和SSL/TLS协议
聊聊HTTPS和SSL/TLS协议
程序员最害怕的5件事 你中招了吗?
程序员最害怕的5件事 你中招了吗?
我是如何打败拖延症的
我是如何打败拖延症的
为啥Android手机总会越用越慢?
为啥Android手机总会越用越慢?
我跳槽是因为他们的显示器更大
我跳槽是因为他们的显示器更大
程序员和编码员之间的区别
程序员和编码员之间的区别
程序员必看的十大电影
程序员必看的十大电影
“肮脏的”IT工作排行榜
“肮脏的”IT工作排行榜
初级 vs 高级开发者 哪个性价比更高?
初级 vs 高级开发者 哪个性价比更高?
看13位CEO、创始人和高管如何提高工作效率
看13位CEO、创始人和高管如何提高工作效率
亲爱的项目经理,我恨你
亲爱的项目经理,我恨你
中美印日四国程序员比较
中美印日四国程序员比较
当下全球最炙手可热的八位少年创业者
当下全球最炙手可热的八位少年创业者
程序员的鄙视链
程序员的鄙视链
我的丈夫是个程序员
我的丈夫是个程序员
写给自己也写给你 自己到底该何去何从
写给自己也写给你 自己到底该何去何从
鲜为人知的编程真相
鲜为人知的编程真相
做程序猿的老婆应该注意的一些事情
做程序猿的老婆应该注意的一些事情
5款最佳正则表达式编辑调试器
5款最佳正则表达式编辑调试器
总结2014中国互联网十大段子
总结2014中国互联网十大段子
为什么程序员都是夜猫子
为什么程序员都是夜猫子
旅行,写作,编程
旅行,写作,编程
程序猿的崛起——Growth Hacker
程序猿的崛起——Growth Hacker
如何成为一名黑客
如何成为一名黑客
一个程序员的时间管理
一个程序员的时间管理
老程序员的下场
老程序员的下场
60个开发者不容错过的免费资源库
60个开发者不容错过的免费资源库
 程序员的样子
程序员的样子
要嫁就嫁程序猿—钱多话少死的早
要嫁就嫁程序猿—钱多话少死的早
程序员的一天:一寸光阴一寸金
程序员的一天:一寸光阴一寸金
10个调试和排错的小建议
10个调试和排错的小建议
程序员应该关注的一些事儿
程序员应该关注的一些事儿
Web开发者需具备的8个好习惯
Web开发者需具备的8个好习惯
团队中“技术大拿”并非越多越好
团队中“技术大拿”并非越多越好
每天工作4小时的程序员
每天工作4小时的程序员
Web开发人员为什么越来越懒了?
Web开发人员为什么越来越懒了?
程序员眼里IE浏览器是什么样的
程序员眼里IE浏览器是什么样的
软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有