+ 1
C++ printf() versus cout which is more powerful?
I use both printf and cout but , why we use both why not we use one instead. Please help me i would like to figure out there actual purpose of using them.
2 Réponses
+ 3
In C++ you would usually prefer cout. printf is a C function from the C standard library that however still exists in C++ in order to keep comparability to C code. One of the biggest advantages of cout is that you don't need to specify the type of a variable manually. On the other side printf let's you see exactly where a variable is printed inside a string.
Actually Rust combines both advantages, but that's again a whole different story :)
+ 1
In C++ cout is powerful than printf() bcuz, printf() acts as a function while cout is a
code which is actually there for printing anything in C++