Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

134 rindas
5.6KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>fflush (The Red Hat newlib C Library)</title>
  7. <meta name="description" content="fflush (The Red Hat newlib C Library)">
  8. <meta name="keywords" content="fflush (The Red Hat newlib C Library)">
  9. <meta name="resource-type" content="document">
  10. <meta name="distribution" content="global">
  11. <meta name="Generator" content="makeinfo">
  12. <link href="index.html#Top" rel="start" title="Top">
  13. <link href="Document-Index.html#Document-Index" rel="index" title="Document Index">
  14. <link href="Document-Index.html#SEC_Contents" rel="contents" title="Table of Contents">
  15. <link href="Stdio.html#Stdio" rel="up" title="Stdio">
  16. <link href="fgetc.html#fgetc" rel="next" title="fgetc">
  17. <link href="ferror.html#ferror" rel="prev" title="ferror">
  18. <style type="text/css">
  19. <!--
  20. a.summary-letter {text-decoration: none}
  21. blockquote.indentedblock {margin-right: 0em}
  22. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  23. blockquote.smallquotation {font-size: smaller}
  24. div.display {margin-left: 3.2em}
  25. div.example {margin-left: 3.2em}
  26. div.lisp {margin-left: 3.2em}
  27. div.smalldisplay {margin-left: 3.2em}
  28. div.smallexample {margin-left: 3.2em}
  29. div.smalllisp {margin-left: 3.2em}
  30. kbd {font-style: oblique}
  31. pre.display {font-family: inherit}
  32. pre.format {font-family: inherit}
  33. pre.menu-comment {font-family: serif}
  34. pre.menu-preformatted {font-family: serif}
  35. pre.smalldisplay {font-family: inherit; font-size: smaller}
  36. pre.smallexample {font-size: smaller}
  37. pre.smallformat {font-family: inherit; font-size: smaller}
  38. pre.smalllisp {font-size: smaller}
  39. span.nolinebreak {white-space: nowrap}
  40. span.roman {font-family: initial; font-weight: normal}
  41. span.sansserif {font-family: sans-serif; font-weight: normal}
  42. ul.no-bullet {list-style: none}
  43. -->
  44. </style>
  45. </head>
  46. <body lang="en">
  47. <a name="fflush"></a>
  48. <div class="header">
  49. <p>
  50. Next: <a href="fgetc.html#fgetc" accesskey="n" rel="next">fgetc</a>, Previous: <a href="ferror.html#ferror" accesskey="p" rel="prev">ferror</a>, Up: <a href="Stdio.html#Stdio" accesskey="u" rel="up">Stdio</a> &nbsp; [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
  51. </div>
  52. <hr>
  53. <a name="fflush_002c-fflush_005funlocked_002d_002d_002dflush-buffered-file-output"></a>
  54. <h3 class="section">4.9 <code>fflush</code>, <code>fflush_unlocked</code>&mdash;flush buffered file output</h3>
  55. <a name="index-fflush"></a>
  56. <a name="index-fflush_005funlocked"></a>
  57. <a name="index-_005ffflush_005fr"></a>
  58. <a name="index-_005ffflush_005funlocked_005fr"></a>
  59. <p><strong>Synopsis</strong>
  60. </p><div class="example">
  61. <pre class="example">#include &lt;stdio.h&gt;
  62. int fflush(FILE *<var>fp</var>);
  63. #define _BSD_SOURCE
  64. #include &lt;stdio.h&gt;
  65. int fflush_unlocked(FILE *<var>fp</var>);
  66. #include &lt;stdio.h&gt;
  67. int _fflush_r(struct _reent *<var>reent</var>, FILE *<var>fp</var>);
  68. #define _BSD_SOURCE
  69. #include &lt;stdio.h&gt;
  70. int _fflush_unlocked_r(struct _reent *<var>reent</var>, FILE *<var>fp</var>);
  71. </pre></div>
  72. <p><strong>Description</strong><br>
  73. The <code>stdio</code> output functions can buffer output before delivering it
  74. to the host system, in order to minimize the overhead of system calls.
  75. </p>
  76. <p>Use <code>fflush</code> to deliver any such pending output (for the file
  77. or stream identified by <var>fp</var>) to the host system.
  78. </p>
  79. <p>If <var>fp</var> is <code>NULL</code>, <code>fflush</code> delivers pending output from all
  80. open files.
  81. </p>
  82. <p>Additionally, if <var>fp</var> is a seekable input stream visiting a file
  83. descriptor, set the position of the file descriptor to match next
  84. unread byte, useful for obeying POSIX semantics when ending a process
  85. without consuming all input from the stream.
  86. </p>
  87. <p><code>fflush_unlocked</code> is a non-thread-safe version of <code>fflush</code>.
  88. <code>fflush_unlocked</code> may only safely be used within a scope
  89. protected by flockfile() (or ftrylockfile()) and funlockfile(). This
  90. function may safely be used in a multi-threaded program if and only
  91. if they are called while the invoking thread owns the (FILE *)
  92. object, as is the case after a successful call to the flockfile() or
  93. ftrylockfile() functions. If threads are disabled, then
  94. <code>fflush_unlocked</code> is equivalent to <code>fflush</code>.
  95. </p>
  96. <p>The alternate functions <code>_fflush_r</code> and <code>_fflush_unlocked_r</code> are
  97. reentrant versions, where the extra argument <var>reent</var> is a pointer to
  98. a reentrancy structure, and <var>fp</var> must not be NULL.
  99. </p>
  100. <br>
  101. <p><strong>Returns</strong><br>
  102. <code>fflush</code> returns <code>0</code> unless it encounters a write error; in that
  103. situation, it returns <code>EOF</code>.
  104. </p>
  105. <br>
  106. <p><strong>Portability</strong><br>
  107. ANSI C requires <code>fflush</code>. The behavior on input streams is only
  108. specified by POSIX, and not all implementations follow POSIX rules.
  109. </p>
  110. <p><code>fflush_unlocked</code> is a BSD extension also provided by GNU libc.
  111. </p>
  112. <p>No supporting OS subroutines are required.
  113. </p>
  114. <br>
  115. <hr>
  116. <div class="header">
  117. <p>
  118. Next: <a href="fgetc.html#fgetc" accesskey="n" rel="next">fgetc</a>, Previous: <a href="ferror.html#ferror" accesskey="p" rel="prev">ferror</a>, Up: <a href="Stdio.html#Stdio" accesskey="u" rel="up">Stdio</a> &nbsp; [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
  119. </div>
  120. </body>
  121. </html>