📄 fopen.html
字号:
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The named file is a character special or block special file, and the device associated with this special file does not exist. <imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EOVERFLOW]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The named file is a regular file and the size of the file cannot be represented correctly in an object of type <b>off_t</b>. <imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EROFS]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The named file resides on a read-only file system and <i>mode</i> requires write access. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>The <i>fopen</i>() function may fail if:</p><dl compact><dt>[EINVAL]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The value of the <i>mode</i> argument is not valid. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ELOOP]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the <i>path</i> argument. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EMFILE]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">{FOPEN_MAX} streams are currently open in the calling process. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EMFILE]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">{STREAM_MAX} streams are currently open in the calling process. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ENAMETOOLONG]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ENOMEM]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Insufficient storage space is available. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ETXTBSY]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The file is a pure procedure (shared text) file that is being executed and <i>mode</i> requires write access. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_176_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_176_06_01"></a>Opening a File</h5><p>The following example tries to open the file named <b>file</b> for reading. The <i>fopen</i>() function returns a file pointerthat is used in subsequent <a href="../functions/fgets.html"><i>fgets</i>()</a> and <a href="../functions/fclose.html"><i>fclose</i>()</a> calls. If the program cannot open the file, it just ignores it.</p><pre><tt>#include <stdio.h>...FILE *fp;...void rgrep(const char *file){... if ((fp = fopen(file, "r")) == NULL) return;...}</tt></pre></blockquote><h4><a name="tag_03_176_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_176_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_176_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_176_10"></a>SEE ALSO</h4><blockquote><p><a href="fclose.html"><i>fclose</i>()</a> , <a href="fdopen.html"><i>fdopen</i>()</a> , <a href="freopen.html"><i>freopen</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/stdio.h.html"><i><stdio.h></i></a></p></blockquote><h4><a name="tag_03_176_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 1. Derived from Issue 1 of the SVID.</p></blockquote><h4><a name="tag_03_176_12"></a>Issue 5</h4><blockquote><p>Large File Summit extensions are added.</p></blockquote><h4><a name="tag_03_176_13"></a>Issue 6</h4><blockquote><p>Extensions beyond the ISO C standard are marked.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>In the DESCRIPTION, text is added to indicate setting of the offset maximum in the open file description. This change is tosupport large files.</p></li><li><p>In the ERRORS section, the [EOVERFLOW] condition is added. This change is to support large files.</p></li><li><p>The [ELOOP] mandatory error condition is added.</p></li><li><p>The [EINVAL], [EMFILE], [ENAMETOOLONG], [ENOMEM], and [ETXTBSY] optional error conditions are added.</p></li></ul><p>The DESCRIPTION is updated to avoid use of the term "must" for application requirements.</p><p>The following changes are made for alignment with the ISO/IEC 9899:1999 standard:</p><ul><li><p>The prototype for <i>fopen</i>() is updated.</p></li><li><p>The DESCRIPTION is updated to note that if the argument <i>mode</i> points to a string other than those listed, then thebehavior is undefined.</p></li></ul><p>The wording of the mandatory [ELOOP] error condition is updated, and a second optional [ELOOP] error condition is added.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -