缓冲标准输出 (STDOUT)

发布于 2024-10-09 05:44:21 字数 54 浏览 0 评论 0原文

默认情况下,STDOUT 是无缓冲的吗?如果不是,它的默认缓冲类型是什么

谢谢

By default, is STDOUT unbuffered? If not what is the type of its default buffering

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扛刀软妹 2024-10-16 05:44:21

您没有提供一种语言,但假设您正在使用 C 的 stdio 函数(fopen() 等)或使用这些函数的语言(出于可移植性原因,大多数语言都这样做):

这取决于底层的C运行时库。

大多数库都会尝试检测STDOUT是否连接到终端,如果是,则避免缓冲,如果是,则执行块缓冲(例如,我的Linux系统一次缓冲8Kb)不是。

You didn't give a language, but assuming that you're using C's stdio functions (fopen() etc.) or a language that uses these (and most do, for portability reasons):

It depends on the underlying C runtime library.

Most libraries will try to detect whether STDOUT is connected to a terminal, and avoid buffering if so, and perform block buffering (e.g. my Linux system buffers 8Kb at a time) if not.

山川志 2024-10-16 05:44:21

简短回答:默认情况下,STDOUT 通常是无缓冲的。如果这对您来说是个问题,可以使用 fflush(stdout); ,但这很少

Short Answer: By default STDOUT is usually unbuffered. If this is a problem for you, there is fflush(stdout); but that is rarely needed

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文