blob: 700b176adea41c4a456840746e6075d8c15d4de6 [file]
<html lang="en">
<head>
<title>fclose - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Stdio.html#Stdio" title="Stdio">
<link rel="prev" href="dprintf.html#dprintf" title="dprintf">
<link rel="next" href="fcloseall.html#fcloseall" title="fcloseall">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="fclose"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="fcloseall.html#fcloseall">fcloseall</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="dprintf.html#dprintf">dprintf</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stdio.html#Stdio">Stdio</a>
<hr>
</div>
<h3 class="section">4.4 <code>fclose</code>&mdash;close a file</h3>
<p><a name="index-fclose-154"></a><a name="index-g_t_005ffclose_005fr-155"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;stdio.h&gt;
int fclose(FILE *<var>fp</var>);
int _fclose_r(struct _reent *<var>reent</var>, FILE *<var>fp</var>);
</pre>
<p><strong>Description</strong><br>
If the file or stream identified by <var>fp</var> is open, <code>fclose</code> closes
it, after first ensuring that any pending data is written (by calling
<code>fflush(</code><var>fp</var><code>)</code>).
<p>The alternate function <code>_fclose_r</code> is a reentrant version.
The extra argument <var>reent</var> is a pointer to a reentrancy structure.
<p><br>
<strong>Returns</strong><br>
<code>fclose</code> returns <code>0</code> if successful (including when <var>fp</var> is
<code>NULL</code> or not an open file); otherwise, it returns <code>EOF</code>.
<p><br>
<strong>Portability</strong><br>
<code>fclose</code> is required by ANSI C.
<p>Required OS subroutines: <code>close</code>, <code>fstat</code>, <code>isatty</code>, <code>lseek</code>,
<code>read</code>, <code>sbrk</code>, <code>write</code>.
<p><br>
</body></html>