Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::endl 描述有误 #47

Open
Mq-b opened this issue Sep 24, 2024 · 2 comments
Open

std::endl 描述有误 #47

Mq-b opened this issue Sep 24, 2024 · 2 comments

Comments

@Mq-b
Copy link
Contributor

Mq-b commented Sep 24, 2024

endl 是一个典型的以讹传讹错误写法,只有当你的输出是指向另一个进程的管道时,其附带的刷新功能才有作用。

当输出是管道时,cout 需要 endl 才能刷新。
当输出是普通控制台时,cout 需要 endl 才能刷新。

我认为此处最后一句存在问题。普通控制台并不一定需要 endl 才能刷新。

endl 操纵符大多时候都是冗余的,"\n" 大多数时候也会进行刷新,即使是文件读写也很少会使用 endl

@archibate
Copy link
Contributor

想说的应该是:

当输出是管道时,cout 需要 endl 才能刷新。
当输出是普通控制台时,cout 只需 '\n' 就能刷新,无需 endl。

复制粘贴害的。

@archibate
Copy link
Contributor

archibate commented Sep 24, 2024

已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants