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.
The problem is that `cin` has a lot of overhead involved because it gives you an abstraction layer above `scanf()` calls. You shouldn't use `scanf()` over `cin` if you are writing C++ software because that is want `cin` is for. If you want performance, you probably wouldn't be writing I/O in C++ anyway.