Fastest I/O C++?

Which is the most fast and efficient method for input output in c++ for large chunks of data?
I know that the performance increases from cout cin to scanf printf,but I see people using much better methods here.If anyone could share one such method with a possible explanation to it,that would be great :smiley:


Actually,cin and cout can be faster than scanf() and printf(). But it depends.If you are not using scanf() and printf() ,then at the start of main() use std::ios_base::sync_with_stdio(false);.This turns off the intermixing calls to scanf()/printf() with operations on cin/cout. Actually,by default cin/cout wastes time synchronizing with c library’s stdio buffers.
for more info,just have a look on the link : interacting with C

But people use stuff like register char c = getche_unlocked() something something etc…in C,which method is that?Is there any explanation?Can I use it in C++?

I would like you to go through the following links:


Also you can look at some of the submissions of this question. The top solutions of this question uses good fast i/o functions.
I personally use this code for fast input output.

Excuse me brother,

I hope both are sufficient enough to quench your yearning.


It seems that, the difference by using std::ios_base::sync_with_stdio(false) is only observable if the input contains huge number of large integers, i.e. long or long long.