setvbuf()中的字母'v'是什么意思?[closed]

lo8azlld  于 2022-12-03  发布在  其他
关注(0)|答案(2)|浏览(140)

已关闭。此问题为opinion-based。当前不接受答案。
**想要改进此问题吗?**请更新问题,以便editing this post可以使用事实与引用来回答.

13天前关闭。
Improve this question
最近我发现了两个函数setbuf()setvbuf()可以用来设置流缓冲区。setvbuf这个名字中的字母v是什么意思?是variousversion还是别的什么?

6xfqseft

6xfqseft1#

我没有找到任何关于“v”的解释,但我猜它可能是“变量”,因为它允许指定缓冲区的大小和模式。

svmlkihl

svmlkihl2#

V可以是变量,也可以是值,这要看上下文。我们知道setbuf()函数没有返回值,所以unix系统设计者给了v(value)来区分setvbuf()和setbuf()。这个函数成功返回零,否则返回非零值。请看下面的说明。

1. IBM公司

一般描述控制指定流的缓冲策略和缓冲区大小。流指针必须指向打开的文件,并且setvbuf()必须是对文件的第一个操作。

Value
    Meaning
_IONBF
    No buffer is used.
_IOFBF
    Full buffering is used for input and output. Use buf as the buffer and size as the size of the buffer.
_IOLBF
    Line buffering is used for text stream I/O and terminal I/O. The buffer is flushed when a newline character is used (text stream), when the buffer is full, or when input is requested (terminal). The value for size must be greater than 0.

https://www.ibm.com/docs/en/zos/2.2.0?topic=functions-setvbuf-control-buffering

2.信息(汉堡)

说明:
使用setvbuf指定要为fp标识的文件或流指定哪种缓冲,方法是使用以下值之一(来自stdio.h)作为mode参数:

_IONBF
Do not use a buffer; send output directly to the host system for the file or stream identified by fp.

_IOFBF
Use full output buffering; output will be passed on to the host system only when the buffer is full, or when an input operation intervenes.

_IOLBF
Use line buffering; pass on output to the host system at every newline, as well as when the buffer is full, or when an input operation intervenes.

https://users.informatik.haw-hamburg.de/~krabat/FH-Labor/gnupro/4_GNUPro_Libraries/a_GNUPro_C_Library/libcsetvbufspecify_file_or_stream_bu.html

相关问题