gpt4 book ai didi

c++ - setbuf 什么时候有用(除了 NULL 值)?

转载 作者:行者123 更新时间:2023-11-30 21:38:04 25 4
gpt4 key购买 nike

setbuf 函数什么时候有用(NULL 值除外)?

我尝试发明这些例子,但我还是做不到。
我了解 setvbuf 如何发挥作用,但我不了解 setbuf

最佳答案

基本上,setvbuf 是一个较新的 API,其逻辑与 setbuf 相同。 setbuf 的存在是为了与 setvbuf 存在之前编写的程序兼容。

换句话说,除非您正在处理已经使用 setbuf 的代码,否则请忽略它的存在。

Reference :

Function: void setbuf (FILE *stream, char *buf)

  • If buf is a null pointer, the effect of this function is equivalent to calling setvbuf with a mode argument of _IONBF. Otherwise, it is equivalent to calling setvbuf with buf, and a mode of _IOFBF and a size argument of BUFSIZ.
  • The setbuf function is provided for compatibility with old code; use setvbuf in all new programs.

关于c++ - setbuf 什么时候有用(除了 NULL 值)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20650861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com