1<html lang="en"> 2<head> 3<title>fflush - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Stdio.html#Stdio" title="Stdio"> 9<link rel="prev" href="ferror.html#ferror" title="ferror"> 10<link rel="next" href="fgetc.html#fgetc" title="fgetc"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<meta http-equiv="Content-Style-Type" content="text/css"> 13<style type="text/css"><!-- 14 pre.display { font-family:inherit } 15 pre.format { font-family:inherit } 16 pre.smalldisplay { font-family:inherit; font-size:smaller } 17 pre.smallformat { font-family:inherit; font-size:smaller } 18 pre.smallexample { font-size:smaller } 19 pre.smalllisp { font-size:smaller } 20 span.sc { font-variant:small-caps } 21 span.roman { font-family:serif; font-weight:normal; } 22 span.sansserif { font-family:sans-serif; font-weight:normal; } 23--></style> 24<link rel="stylesheet" type="text/css" href="../cs.css"> 25</head> 26<body> 27<div class="node"> 28<a name="fflush"></a> 29<p> 30Next: <a rel="next" accesskey="n" href="fgetc.html#fgetc">fgetc</a>, 31Previous: <a rel="previous" accesskey="p" href="ferror.html#ferror">ferror</a>, 32Up: <a rel="up" accesskey="u" href="Stdio.html#Stdio">Stdio</a> 33<hr> 34</div> 35 36<h3 class="section">4.9 <code>fflush</code>—flush buffered file output</h3> 37 38<p><a name="index-fflush-162"></a><a name="index-g_t_005ffflush_005fr-163"></a><strong>Synopsis</strong> 39<pre class="example"> #include <stdio.h> 40 int fflush(FILE *<var>fp</var>); 41 42 int _fflush_r(struct _reent *<var>reent</var>, FILE *<var>fp</var>); 43 44</pre> 45 <p><strong>Description</strong><br> 46The <code>stdio</code> output functions can buffer output before delivering it 47to the host system, in order to minimize the overhead of system calls. 48 49 <p>Use <code>fflush</code> to deliver any such pending output (for the file 50or stream identified by <var>fp</var>) to the host system. 51 52 <p>If <var>fp</var> is <code>NULL</code>, <code>fflush</code> delivers pending output from all 53open files. 54 55 <p>Additionally, if <var>fp</var> is a seekable input stream visiting a file 56descriptor, set the position of the file descriptor to match next 57unread byte, useful for obeying POSIX semantics when ending a process 58without consuming all input from the stream. 59 60 <p>The alternate function <code>_fflush_r</code> is a reentrant version, where the 61extra argument <var>reent</var> is a pointer to a reentrancy structure, and 62<var>fp</var> must not be NULL. 63 64 <p><br> 65<strong>Returns</strong><br> 66<code>fflush</code> returns <code>0</code> unless it encounters a write error; in that 67situation, it returns <code>EOF</code>. 68 69 <p><br> 70<strong>Portability</strong><br> 71ANSI C requires <code>fflush</code>. The behavior on input streams is only 72specified by POSIX, and not all implementations follow POSIX rules. 73 74 <p>No supporting OS subroutines are required. 75 76 <p><br> 77 78 </body></html> 79 80