1

I have frequently encountered people writing in their c++ code ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);. I do not understand what exactly is the reason of printf() and scanf() being faster than cout and cin. I understand that cout and cin are streams and not functions. However, I am more curious to know what is the underlying mechanism which makes cout and cin slower than printf() and scanf().

2
  • 1
    cin and cout are tied together by default. Performing a read on cin first flushes cout if it has buffered data waiting to be output. C functions like printf() and scanf() are not similarly tied together Commented Jan 24, 2020 at 6:10
  • 1
    This post can be helpful. Commented Jan 24, 2020 at 6:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.