⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fflush.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>fflush</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="fflush"></a> <a name="tag_03_160"></a><!-- fflush --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_160_01"></a>NAME</h4><blockquote>fflush - flush a stream</blockquote><h4><a name="tag_03_160_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/stdio.h.html">stdio.h</a>&gt;<br><br> int fflush(FILE *</tt><i>stream</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_160_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> The functionality described on this reference page is aligned with the ISO&nbsp;C standard. Any conflict between therequirements described here and the ISO&nbsp;C standard is unintentional. This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 defers tothe ISO&nbsp;C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>If <i>stream</i> points to an output stream or an update stream in which the most recent operation was not input,<i>fflush</i>() shall cause any unwritten data for that stream to be written to the file, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;and the<i>st_ctime</i> and <i>st_mtime</i> fields of the underlying file shall be marked for update. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>If <i>stream</i> is a null pointer, <i>fflush</i>() shall perform this flushing action on all streams for which the behavior isdefined above.</p></blockquote><h4><a name="tag_03_160_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>fflush</i>() shall return 0; otherwise, it shall set the error indicator for the stream, returnEOF, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">&nbsp;and set <i>errno</i> to indicate the error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_160_05"></a>ERRORS</h4><blockquote><p>The <i>fflush</i>() function shall fail if:</p><dl compact><dt>[EAGAIN]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The O_NONBLOCK flag is set for the file descriptor underlying <i>stream</i> and the process would be delayed in the writeoperation. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EBADF]</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 descriptor underlying <i>stream</i> is not valid. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EFBIG]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Anattempt was made to write a file that exceeds the maximum file size. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EFBIG]</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">An attempt was made to write a file that exceeds the process' file size limit. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></dd><dt>[EFBIG]</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 regular file and an attempt was made to write at or beyond the offset maximum associated with the correspondingstream. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EINTR]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i>fflush</i>() function was interrupted by a signal. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EIO]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The process is a member of a background process group attempting to write to its controlling terminal, TOSTOP is set, the processis neither ignoring nor blocking SIGTTOU, and the process group of the process is orphaned. This error may also be returned underimplementation-defined conditions. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[ENOSPC]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">There was no free space remaining on the device containing the file. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EPIPE]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Anattempt is made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal shall also be sent to thethread. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>The <i>fflush</i>() function may fail if:</p><dl compact><dt>[ENXIO]</dt><dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Arequest was made of a nonexistent device, or the request was outside the capabilities of the device. <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_160_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_160_06_01"></a>Sending Prompts to Standard Output</h5><p>The following example uses <a href="../functions/printf.html"><i>printf</i>()</a> calls to print a series of prompts forinformation the user must enter from standard input. The <i>fflush</i>() calls force the output to standard output. The<i>fflush</i>() function is used because standard output is usually buffered and the prompt may not immediately be printed on theoutput or terminal. The <a href="../functions/gets.html"><i>gets</i>()</a> calls read strings from standard input and place theresults in variables, for use later in the program.</p><pre><tt>#include &lt;stdio.h&gt;...char user[100];char oldpasswd[100];char newpasswd[100];...printf("User name: ");fflush(stdout);gets(user);<br>printf("Old password: ");fflush(stdout);gets(oldpasswd);<br>printf("New password: ");fflush(stdout);gets(newpasswd);...</tt></pre></blockquote><h4><a name="tag_03_160_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_160_08"></a>RATIONALE</h4><blockquote><p>Data buffered by the system may make determining the validity of the position of the current file descriptor impractical. Thus,enforcing the repositioning of the file descriptor after <i>fflush</i>() on streams open for <a href="../functions/read.html"><i>read</i>()</a> is not mandated by IEEE&nbsp;Std&nbsp;1003.1-2001.</p></blockquote><h4><a name="tag_03_160_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_160_10"></a>SEE ALSO</h4><blockquote><p><a href="getrlimit.html"><i>getrlimit</i>()</a> , <a href="ulimit.html"><i>ulimit</i>()</a> , the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/stdio.h.html"><i>&lt;stdio.h&gt;</i></a></p></blockquote><h4><a name="tag_03_160_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_160_12"></a>Issue 5</h4><blockquote><p>Large File Summit extensions are added.</p></blockquote><h4><a name="tag_03_160_13"></a>Issue 6</h4><blockquote><p>Extensions beyond the ISO&nbsp;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>The [EFBIG] error is added as part of the large file support extensions.</p></li><li><p>The [ENXIO] optional error condition is added.</p></li></ul><p>The RETURN VALUE section is updated to note that the error indicator shall be set for the stream. This is for alignment with theISO/IEC&nbsp;9899:1999 standard.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; 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 + -