When I search on the internet for the difference between these two libraries, everyone says that <iostream>
is the standard I/O library of C++ and <cstdio>
is for C. My professor says that cin>>
and cout<<
are not good functions and if we use cin>>
many times our application will definitely crash. He also says that stdio
provides nearly 3 times faster input and output than iostream
. However, I prefer using iostream
because it is more convenient, and also I don't know if my professor is right.
So what do you advise me to use?
Using iostream
should not make your program crash. It can be slow, but that's only because it's trying to interoperate with stdio
. That synchronization can be turned off1. iostream
is the idiomatic C++ way to get input, and I'd recommend its use over stdio
functions in most cases when using C++.
1 using std::ios::sync_with_stdio(false);