stderr 和 stdout - 未缓冲与缓冲? [英] stderr and stdout - not buffered vs. buffered?

查看:39
本文介绍了stderr 和 stdout - 未缓冲与缓冲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小程序,它根据不同的事件具有各种控制台输出字符串.当我在寻找发送这些消息的最佳方式时,我遇到了一些令人困惑的事情.

I was writing a small program that had various console output strings depending upon different events. As I was looking up the best way to send these messages I came across something that was a bit confusing.

我已经读到 stderr 用于将消息直接发送到控制台 - not buffered.相比之下,我读到 stdoutbuffered 并且通常用于将消息重定向到各种 streams?,这可能是也可能不是错误消息,输出文件或其他一些媒体.

I have read that stderr is used to shoot messages directly to the console - not buffered. While, in contrast, I read that stdout is buffered and is typically used to redirect messages to various streams?, that may or may not be error messages, to an output file or some other medium.

什么是缓冲的和不缓冲的有什么区别?当我读到消息被直接发送到输出并且没有缓冲时,这是有道理的..但同时我意识到我并不完全确定缓冲的含义.

What is the difference when something is said to be buffered and not buffered? It made sense when I was reading that the message is shot directly to the output and is not buffered .. but at the same time I realized that I was not entirely sure what it meant to be buffered.

推荐答案

通常情况下,stdout 是行缓冲的,这意味着发送到 stdout 的字符堆叠"直到一个换行符到达,此时全部输出.

Typically, stdout is line buffered, meaning that characters sent to stdout "stack up" until a newline character arrives, at which point that are all outputted.

这篇关于stderr 和 stdout - 未缓冲与缓冲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆