C++ printf() versus cout which is more powerful? | Sololearn: Learn to code for FREE!
+ 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.

9th Apr 2020, 12:34 PM
D ╠▓E ╠▓S ╠▓S ╠▓I ╠▓E ╠▓- ╠▓B ╠▓A ╠▓H ╠▓I ╠▓R ╠▓U ╠▓
D ╠▓E ╠▓S ╠▓S ╠▓I ╠▓E ╠▓- ╠▓B ╠▓A ╠▓H ╠▓I ╠▓R ╠▓U ╠▓ - avatar
2 Antworten
+ 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 :)
9th Apr 2020, 12:44 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 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++
11th Apr 2020, 8:07 PM
Het Patel
Het Patel - avatar