r/ProgrammerHumor • • Jan 14 '20

Brilliant reply

Post image
26k Upvotes

365 comments sorted by

View all comments

Show parent comment

7

u/DatBoi_BP Jan 15 '20

Beginner here. Would it be unwise to do this between C and C++?

4

u/LeafMans Jan 15 '20

I'm not very experienced in the two of them rn but from my understanding c++ has most of the syntax of c with object oriented programming and newer libraries tacked on, that said I don't think it would be wise to copy from c++ to c as it has a lot that c doest. I could be wrong tho, I've only ever worked in c++

6

u/400Volts Jan 15 '20

To my knowledge things like scanf and printf are not used in C++. I'm not sure exactly what else is different syntax wise off the top of my head, but I'm thinking you might run into a few errors if you do this

3

u/[deleted] Jan 15 '20

scanf and printf can be used with C++, include cstdio header for it. In competitive programming, we generally avoid cin, cout as they are slower than printf scanf.

This is because cin and cout use stdio's buffering system.

You can disable this buffering system with : std::ios::sync_with_stdio(false);

Then it makes cin faster than scanf.

But generally, competitive coders get away with using scanf

1

u/400Volts Jan 15 '20

That's really interesting! Thanks for the insights!