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.

pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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>setvbuf (The Red Hat newlib C Library)</title>
  7. <meta name="description" content="setvbuf (The Red Hat newlib C Library)">
  8. <meta name="keywords" content="setvbuf (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="siprintf.html#siprintf" rel="next" title="siprintf">
  17. <link href="setlinebuf.html#setlinebuf" rel="prev" title="setlinebuf">
  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="setvbuf"></a>
  48. <div class="header">
  49. <p>
  50. Next: <a href="siprintf.html#siprintf" accesskey="n" rel="next">siprintf</a>, Previous: <a href="setlinebuf.html#setlinebuf" accesskey="p" rel="prev">setlinebuf</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="setvbuf_002d_002d_002dspecify-file-or-stream-buffering"></a>
  54. <h3 class="section">4.58 <code>setvbuf</code>&mdash;specify file or stream buffering</h3>
  55. <a name="index-setvbuf"></a>
  56. <p><strong>Synopsis</strong>
  57. </p><div class="example">
  58. <pre class="example">#include &lt;stdio.h&gt;
  59. int setvbuf(FILE *<var>fp</var>, char *<var>buf</var>,
  60. int <var>mode</var>, size_t <var>size</var>);
  61. </pre></div>
  62. <p><strong>Description</strong><br>
  63. Use <code>setvbuf</code> to specify what kind of buffering you want for the
  64. file or stream identified by <var>fp</var>, by using one of the following
  65. values (from <code>stdio.h</code>) as the <var>mode</var> argument:
  66. </p>
  67. <dl compact="compact">
  68. <dt><code>_IONBF</code></dt>
  69. <dd><p>Do not use a buffer: send output directly to the host system for the
  70. file or stream identified by <var>fp</var>.
  71. </p>
  72. </dd>
  73. <dt><code>_IOFBF</code></dt>
  74. <dd><p>Use full output buffering: output will be passed on to the host system
  75. only when the buffer is full, or when an input operation intervenes.
  76. </p>
  77. </dd>
  78. <dt><code>_IOLBF</code></dt>
  79. <dd><p>Use line buffering: pass on output to the host system at every
  80. newline, as well as when the buffer is full, or when an input
  81. operation intervenes.
  82. </p></dd>
  83. </dl>
  84. <p>Use the <var>size</var> argument to specify how large a buffer you wish. You
  85. can supply the buffer itself, if you wish, by passing a pointer to a
  86. suitable area of memory as <var>buf</var>. Otherwise, you may pass <code>NULL</code>
  87. as the <var>buf</var> argument, and <code>setvbuf</code> will allocate the buffer.
  88. </p>
  89. <br>
  90. <p><strong>Warnings</strong><br>
  91. You may only use <code>setvbuf</code> before performing any file operation other
  92. than opening the file.
  93. </p>
  94. <p>If you supply a non-null <var>buf</var>, you must ensure that the associated
  95. storage continues to be available until you close the stream
  96. identified by <var>fp</var>.
  97. </p>
  98. <br>
  99. <p><strong>Returns</strong><br>
  100. A <code>0</code> result indicates success, <code>EOF</code> failure (invalid <var>mode</var> or
  101. <var>size</var> can cause failure).
  102. </p>
  103. <br>
  104. <p><strong>Portability</strong><br>
  105. Both ANSI C and the System V Interface Definition (Issue 2) require
  106. <code>setvbuf</code>. However, they differ on the meaning of a <code>NULL</code> buffer
  107. pointer: the SVID issue 2 specification says that a <code>NULL</code> buffer
  108. pointer requests unbuffered output. For maximum portability, avoid
  109. <code>NULL</code> buffer pointers.
  110. </p>
  111. <p>Both specifications describe the result on failure only as a
  112. nonzero value.
  113. </p>
  114. <p>Supporting OS subroutines required: <code>close</code>, <code>fstat</code>, <code>isatty</code>,
  115. <code>lseek</code>, <code>read</code>, <code>sbrk</code>, <code>write</code>.
  116. </p>
  117. <br>
  118. <hr>
  119. <div class="header">
  120. <p>
  121. Next: <a href="siprintf.html#siprintf" accesskey="n" rel="next">siprintf</a>, Previous: <a href="setlinebuf.html#setlinebuf" accesskey="p" rel="prev">setlinebuf</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>
  122. </div>
  123. </body>
  124. </html>