簡體   English   中英

setvbuf() 中的字母“v”是什么意思?

[英]What's the meaning of the letter ‘v’ in setvbuf()?

最近發現有兩個函數setbuf()setvbuf()可以用來設置流緩沖區。 setvbuf名稱中的字母v是什么意思? 它是variousversion還是其他什么?

我在任何地方都沒有找到對 'v' 的任何解釋,但我猜它可能是 'variable',因為它允許指定緩沖區的大小和模式。

根據上下文,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.informatik(hamburg.de)

描述:

通過使用以下值之一(來自 stdio.h)作為 mode 參數,使用 setvbuf 指定您想要為 fp 標識的文件或流的緩沖類型:

_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/libcs​​etvbufspecify_file_or_stream_bu.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM