SPyofgameNoImouto's blog

By SPyofgameNoImouto, history, 7 weeks ago, In English

There have been countless blogs about whether one should choose scanf/printf, or cin/cout as the main methods for getting inputs/outputs for C++. There are advantages and disadvantages of each kind, like the ability to easily format outputs, stream operator overloading, or not having to care about the decltype, etc.

But, from what I have seen, there are rarely any blogs that I can find myself, that mention the combination of cin/printf. This seems like a pretty good combination, and I have seen one or two people using it. One can get inputs without having to painfully type & every time, and nicely formatted outputs without a bunch of << operators.

Is there any disadvantage of this combination? Why do we hardly see anyone using those together?

 
 
 
 
  • Vote: I like it
  • -8
  • Vote: I do not like it

»
7 weeks ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

Because if you want to use cin/cout and scanf/printf together you cannot write in your code ios_base::sync_with_stdio(false);. This line speedups using cin/cout but you cannot then use scanf/printf, and using cin/cout without this line you can get TLE.

  • »
    »
    7 weeks ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I mean, I want to use cin and printf in the same code, cin exclusively for inputs and printf exclusively for outputs. Even with ios_base::sync_with_stdio(false);, they can still work together, as long as I only use either cin or scanf (not both), and the same applies for cout/printf. cin/printf and scanf/cout work.

  • »
    »
    7 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    hey is using cin cout with that line same as using printf and scanf efficiency wise?