Mercurial > hg > Members > kono > nitros9-code
view docs/ccguide/fclose.refentry @ 2437:d26e96c40194
rfm changes
author | aaronwolfe |
---|---|
date | Wed, 24 Feb 2010 00:37:08 +0000 |
parents | c0da1728ed5b |
children |
line wrap: on
line source
<refentry id="fclose"> <refnamediv> <refname>Fclose</refname> <refname>Fflush</refname> <refpurpose>flush or close a file</refpurpose> </refnamediv> <refsynopsisdiv> <funcsynopsis> <funcsynopsisinfo> #include <stdio.h> </funcsynopsisinfo> <funcprototype> <funcdef><function>fclose</function></funcdef> <paramdef>FILE *<parameter>fp</parameter></paramdef> </funcprototype> <funcprototype> <funcdef><function>fflush</function></funcdef> <paramdef>FILE *<parameter>fp</parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1><title>Description</title> <para> Fflush causes a buffer associated with the file pointer "fp" to be cleared by writing out to the file; of course, only if the file was opened for write or update. It is not normally ncesasary to call fflush, but it can be useful when, for example, normal output is to "stdout", and it is wished to send something to "stderr" which is unbuffered. If fflush were not used and "stdout" referred to the terminal, the "stderr" message will appear before large chunks of the "stdout" message even though the latter was written first. </para> <para> Fclose call fflush to clear out the buffer associated with "fp", closes the file, and frees the buffer for use by another fopen call. </para> <para> The exit() system call and normal termination of a program causes fclose to be called for each open file. </para> </refsect1> <refsect1><title>See Also</title> <para> System call <link linkend="close">close()</link>, <link linkend="fopen">fopen()</link>, <link linkend="setbuf">setbuf()</link>. </para> </refsect1> <refsect1><title>Diagnostics</title> <para> EOF is returned if "fp" does not refer to an output file or there is an error writing to the file. </para> </refsect1> </refentry>