“c”是什么意思? cout、cin、cerr 和 clog 中的意思是什么?

发布于 2024-08-21 21:49:10 字数 139 浏览 4 评论 0原文

coutcincerrclog 名称中的“c”是什么意思?

我会说 char 但我还没有找到任何东西来证实它。

What does the "c" mean in the cout, cin, cerr and clog names?

I would say char but I haven't found anything to confirm it.

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

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

发布评论

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

评论(3

岁月如刀 2024-08-28 21:49:10

“c”代表“字符”,因为 iostream 将值映射到字节 (char) 表示形式或从字节 (char) 表示形式映射值。 [Bjarne Stroustrup 的 C++ 风格和技术常见问题解答]

The "c" stands for "character" because iostreams map values to and from byte (char) representations. [Bjarne Stroustrup's C++ Style and Technique FAQ]

老旧海报 2024-08-28 21:49:10

我最初猜测是控制台,以及这个链接确认了这一点。但在看到 Stroustrup 的引用后,这似乎是一个误解,c 代表对于角色

支持该理论并可作为指标的一件事是,对于每个流对象(cincoutcerr 等) .)有一个等效的宽流wcinwcoutwcerr等)。

I originally guessed console, and this link confirmed it. But after seeing the quote from Stroustrup, it seems that's a misconception, and that the c stands for character.

One thing in favor of that theory that can serve as an indicator is the fact that for each stream object (cin, cout, cerr, etc.) there is an equivalent, wide-stream one (wcin, wcout, wcerr, etc.).

短暂陪伴 2024-08-28 21:49:10

FredOverflow 已发现 正确答案,带有指向 Stroustrup 网站的链接。

C++ 标准草案(www.open-std.org 上的 n1905.pdf;我没有确切的链接)似乎表明它来自“C”:“C 标准输出”=>库特

27.3 标准 iostream 对象 [lib.iostream.objects]

1- 标头声明关联的对象
具有标准 C 流的对象
由声明的函数提供
中(27.8.2)。

[...]

27.3.1 窄流对象 [lib.narrow.stream.objects]

istream cin

1- 对象 cin 控制与关联的流缓冲区的输入
对象 stdin,声明于

[...]

FredOverflow has found the right answer with a link toward the Stroustrup web site.

A C++ standard draft (n1905.pdf on www.open-std.org; I don't have the exact link) seems to indicate that it comes from "C" : "C standard output" => cout

27.3 Standard iostream objects [lib.iostream.objects]

1- The header <iostream> declares objects that associate
objects with the standard C streams
provided for by the functions declared
in <cstdio> (27.8.2).

[...]

27.3.1 Narrow stream objects [lib.narrow.stream.objects]

istream cin

1- The object cin controls input from a stream buffer associated with
the object stdin, declared in
<cstdio>.

[...]

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