Can anyone tell me this ? r scanf and printf faster than cout and cin ?
created
last reply
- 5
replies
- 545
views
- 6
users
- 2
links
Can anyone tell me this ? r scanf and printf faster than cout and cin ?
Hello,
I don't know if this is true, but when I was reading FAQ on one of the problem providing sites, I found something, that poke my attention:
Check your input/output methods. In C++, using cin and cout is too slow. Use these, and you will guarantee not being able to solve any problem with a decent amount of input or output. Use printf and scanf instead.
Can someone please clarify this? Is really using scanf() in C++ programs faster than using cin >> something ? If yes, that is it a good practice to use it in C++ programs? I thought that it was C specific, though I am just learning C++...
Yes much faster.
As for practice google e.g. suggests using streams only for logging:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Streams5