I\'ve always heard that C++ file I/O operations are much much slower then C style I/O. But I didn\'t find any practical references on comparatively how slow they actually ar
No, C++ input/output is not substantially slower than C’s – if anything, a modern implementation should be slightly faster on formatted input/output since it doesn’t need to parse a format string, and the formatting is instead determined at compile time through the chaining of the stream operators.
Here are a few caveats to consider in a benchmark:
-O3) to get a fair comparison.std::ios_base::sync_with_stdio(false);)'\n' instead of the (flushing) std::endlregister declarations – it simply makes no difference and modern compilers probably ignore it anyway.