Question: 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++...

Answer: 
The statements `cin` and `cout` in general use seem to be slower than `scanf` and `printf` in C++, but actually they are FASTER!

The thing is: In C++, whenever you use `cin` and `cout`, a synchronization process takes place by default that makes sure that if you use both `scanf` and `cin` in your program, then they both work in sync with each other. This sync process takes time. Hence `cin` and `cout` APPEAR to be slower.

However, if the synchronization process is set to not occur, `cin` is faster than `scanf`.

To skip the sync process, include the following code snippet in your program right in the beginning of `main()`:

```
std::ios::sync_with_stdio(false);

```

Visit [this site](http://www.cplusplus.com/reference/ios/ios_base/sync_with_stdio/) for more information.
Yes iostream is slower than cstdio.  

Yes you probably shouldn't use cstdio if you're developing in C++.  

Having said that, there are even faster ways to get I/O than scanf if you don't care about formatting, type safety, blah, blah, blah...

For instance this is a custom routine to get a number from STDIN:

```
inline int get_number()
{
    int c;        
    int n = 0;

    while ((c = getchar_unlocked()) >= '0' && c <= '9')
    {
        // n = 10 * n + (c - '0');
        n = (n << 3) + ( n << 1 ) + c - '0';
    }
    return n;
}

```