Skip to content

std::endl 描述有误 #47

@Mq-b

Description

@Mq-b

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

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions