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

后端 未结 15 2823
旧时难觅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:35

    Under the hood, they will both use the same code, so speed differences will not matter.

    If you are running on Windows only, the non-standard cprintf() might be faster as it bypasses a lot of the streams stuff.

    However it is an odd requirement. Nobody can read that fast. Why not write output to a file, then the user can browse the file at their leisure?

提交回复
热议问题