📄 setvbuf.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>setvbuf</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_008_516"> </a>NAME</h4><blockquote>setvbuf - assign buffering to a stream</blockquote><h4><a name = "tag_000_008_517"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="stdio.h.html">stdio.h</a>>int setvbuf(FILE *<i>stream</i>, char *<i>buf</i>, int <i>type</i>, size_t <i>size</i>);</code></pre></blockquote><h4><a name = "tag_000_008_518"> </a>DESCRIPTION</h4><blockquote>The<i>setvbuf()</i>function may be used after the stream pointed to by<i>stream</i>is associated with an open file but before any otheroperation is performed on the stream.The argument<i>type</i>determines how<i>stream</i>will be buffered, as follows:_IOFBF causes input/output to be fully buffered;_IOLBF causes input/output to be line buffered;_IONBF causes input/output to be unbuffered.If<i>buf</i>is not a null pointer, the array it points to may be used insteadof a buffer allocated by<i>setvbuf()</i>.The argument<i>size</i>specifies the size of the array.The contents of the array at any time are indeterminate.<p>For information about streams, see<a href="stdio.html">Standard I/O Streans</a>.</blockquote><h4><a name = "tag_000_008_519"> </a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>setvbuf()</i>returns 0. Otherwise, it returns a non-zero value if an invalid value isgiven for<i>type</i>or if the request cannot be honoured.</blockquote><h4><a name = "tag_000_008_520"> </a>ERRORS</h4><blockquote>The<i>setvbuf()</i>function may fail if:<dl compact><dt>[EBADF]<dd>The file descriptor underlying<i>stream</i>is not valid.</dl></blockquote><h4><a name = "tag_000_008_521"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_008_522"> </a>APPLICATION USAGE</h4><blockquote>A common source of error is allocating buffer spaceas an "automatic" variable in a code block, and thenfailing to close the stream in the same block.<p>With<i>setvbuf()</i>,allocating a buffer of<i>size</i>bytes does not necessarily imply that all of<i>size</i>bytes are used for the buffer area.<p>Applications should note that many implementations only provide linebuffering on input from terminal devices.</blockquote><h4><a name = "tag_000_008_523"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_008_524"> </a>SEE ALSO</h4><blockquote><i><a href="fopen.html">fopen()</a></i>,<i><a href="setbuf.html">setbuf()</a></i>,<i><a href="stdio.h.html"><stdio.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -