×

# Fastest I/O C++?

 3 2 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 :D asked 14 Oct '14, 23:50 291●2●3●19 accept rate: 10%

 5 I hope both are sufficient enough to quench your yearning. answered 15 Oct '14, 10:55 2.9k●31●53 accept rate: 9%
 0 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 answered 15 Oct '14, 00:13 206●1●2●9 accept rate: 9%
 0 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++? answered 15 Oct '14, 00:57 291●2●3●19 accept rate: 10%
 0 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. answered 15 Oct '14, 01:29 4★roman28 1.6k●7●14●29 accept rate: 19%
 0 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. answered 02 Jun '17, 23:10 1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,911
×53
×22

question asked: 14 Oct '14, 23:50

question was seen: 20,927 times

last updated: 02 Jun '17, 23:10