About Printf-Scanf and Cin-Cout

c
c-plus-plus
function
input
output

#1

Can anyone please tell me exactly why printf-scanf works faster than cin-cout?


#2

By default the i/o functions cin and cout are meant to synchronise with the library #include<stdio.h> . This makes them slow. You can change this by adding the following line below the int main () line of your function

std::ios_base::sync_with_stdio(false);

Note that after using this line you cannot use any instances of scanf and printf in your program. Else it’ll give you a runtime error SIGSEGV. Also this makes cin and cout a tad bit faster than scanf and printf. You can check that on the problem INTEST.


#3

This link will help you understand better about that.


#4

check out this answer on quora: http://www.quora.com/Is-cin-cout-slower-than-scanf-printf


#5

It wil not increase speed of cout though…

http://codeforces.com/blog/entry/6251