cout or printf which of the two has a faster execution speed C++?

后端 未结 15 2868
旧时难觅i
旧时难觅i 2020-11-27 07:04

I have been coding in C++ for a long time. I always wondered which has a faster execution speed printf or cout?

Situation: I am designing a

15条回答
  •  不知归路
    2020-11-27 07:22

    The reason C++ cout is slow is the default sync with stdio.

    Try executing the following to deactivate this issue.

    ios_base::sync_with_stdio(false)

    http://www.cplusplus.com/reference/iostream/ios_base/sync_with_stdio/

    http://msdn.microsoft.com/es-es/library/7yxhba01.aspx

提交回复
热议问题