Personally, I like cout. What do you guys think?
- SirCrono6
Printable View
Personally, I like cout. What do you guys think?
- SirCrono6
I actually learned C++ before I learned C, so I prefer cout.
However, I have heard the printf is slightly faster. I am not sure if this is true or not, but it is what I have heard.
Still, cout is quite nice. A quick overload of the << operator can make it output pretty much anything. It is pretty nice.
I think if you are programming console, it doesnt really matter which you use. Not many people care about the miniscule difference in how fast text is outputted in console mode.
cout is not used very much in GUI programming, although I do use fstream's quite a lot. fstreams are VERY nice things to have. I love them.
I like printf..... because it's the only one I ever learned. I've taken 3 C classes and have never messed with C++ so far.
cout is more like javascript. I like c's % thingy much more control and easier to output.
>I like c's % thingy much more control and easier to output
Agreed. And if you wish you can apply this style formatting to buffer output if you are using a text setup that isn't the console (ie a graphics setup, that's what I used in AktiF). Though it takes a bit of work, it's worth this rather than redefining formatting yourself.
Gee, this hasn't been done before
cout or printf? None.
I like sprintf best :D cout & printf ain't cool for GUIs.
when I do console stuff, I prefer printf, in fact, I always use C's stdio instead of C++'s iostream.
cout has nifty type-checking. and you can define it for use with new objects you create, like string objects. anything you can do with printf can be done with cout using manipulators.
I use cout because I don't know how to use printf... it looks like you can have more control over it, which would appeal to me if I actually bothered to learn how to use it...
Hey is there any equivalent for sprintf() under C++?
No, cout is faster than printf because cout has compile-time type-checking whereas printf has to parse a string.Quote:
Originally posted by DavidP
However, I have heard the printf is slightly faster. I am not sure if this is true or not, but it is what I have heard.
std::stringstream in <sstream>Quote:
Originally posted by DavidP
Hey is there any equivalent for sprintf() under C++?
>>No, cout is faster than printf because cout has compile-time type-checking whereas printf has to parse a string.
didn't Sunlight proved that it's the other way around, or is my memory playing tricks on me?
printf is faster than cout. You can try measuring the execution time between there and you'll see the big discrepancy, in favor of printf. cout sucks.
I don't know how to use printf. All those %'s and whatever, I can't keep em straight.