C++ iostream vs. C stdio performance/overhead

后端 未结 3 1114
旧巷少年郎
旧巷少年郎 2020-12-18 06:30

I\'m trying to comprehend how to improve the performance of this C++ code to bring it on par with the C code it is based on. The C code looks like this:

#inc         


        
3条回答
  •  离开以前
    2020-12-18 07:21

    As noted in the comments, make sure the actual algorithm for reading input is as good in C++ as in C. And make sure that you have std::ios::sync_with_stdio(false) so the iostreams are not slowed down by synching with C stdio.

    But in my experience, C stdio is faster than C++ iostreams, but the C lib is not typesafe and extensible.

提交回复
热议问题