Hi there, I'm fairly new at C++ so I just have a few quick questions :)
First of all, what's the difference between the printf and cout command and when should I use each one. And second, what's the difference between the scanf and cin command and when should I use which one? :)
Thanks for the advice :) ....
C I/O:printf() and sscanf()
C++ I/O:cout and cin
You can use both since C++ is a more advanced form of C (in simple terms). It is all a matter of preference.
Sorry about the smiley, I forgot to turn off them. Btw, that last post was me.
if you use printf(), outputing variables are little harder.
for example, we have x as a variable:
cout << var;
now with printf() you have to know what you want to output, weather its a number or character(s).
//you use this to output var in number form
//you use this to output var in character form
Golfinguy is right,
sscanf() and printf() are the old C functions for Input and Output
cout and cin and the equivalents in the newer C++
The C++ version is easier to use.
Just get used to seeing the old C style functions as C is at least 20 years old and I beleive older, alot of code is written in plain C - the old farts still use C becuase they can't be taught new tricks.
>the old farts still use C becuase they can't be taught new tricks.
Don't be so quick to assume that, printf does have advantages over cout. Though I prefer to follow a guideline of using C++ I/O when coding C++ and C I/O when coding C. Of course there are exceptions, use whatever works best if you want to be truly flexible :)