printf vs cout
Im new to C/C++ and I vaguely understand the differences between the printf and cout. I have used cout in a few small things I wrote but I see a lot of people using printf too. So, should I stick with cout until I get a better grasp of how things work or is printf a necessity for even beginners?
cout vs printf
printf is old style, but it is not inferior when compared to cout.
however, the speciality of cout is that you dont need to put %d, %c stuff while printing variables, hence the syntax is easier
in reality, cout is an object that encapsulates printf. it overloads operator << for a bunch of types so that it can cat. to the buffer. the buffer is then flushed when the endl is given and the printf is actually called. so the only difference really is that you're dealing with an object that does a lot of your dirty work.
printf comes from c ,c++ uses cout but becouse c++ accepts c type writing people can use printf instead of cout but the new style is cout .
For now I mainly still use printf (my Preference), although as I have just started learning templates I believe I will have problems with printf and templates, i.e., how do you use printf to output a type that can be of any type?
ok.. does anyone know if one performs better than another? It seems printf would be the better choice but I have nothing to base this on...