here is the que:
Q:-what is the basic difference between cout and printf?
i know printf is defined in STDIO.H and cout in IOSTREAM.H.
here is the que:
Q:-what is the basic difference between cout and printf?
i know printf is defined in STDIO.H and cout in IOSTREAM.H.
Well for starters I believe cout is C++.
Favorite Quote:
>For that reason someone invented C++.
BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!
cout is only in C++ because it's a class... there's an entire heirarchy of classes that it derives it's abilities from.
printf does it's thing without classes.
basically, if you're programming in C++, use cout. if you're programming in C, use printf. Some people will say printf is faster, and it is marginally faster, but that's not something you should take into consideration.
cout, being a derived class is more robust, AFAIK.
take all of the above with a grain of salt - I don't know all that much about printf.
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
Maybe printf is similar to wsprintf, which resides in user32.dll
Studying programming languages,
you'll ALWAYS be a student ;-)
>Q:-what is the basic difference between cout and printf?
The basic difference is that printf is a function and cout is an object. You pass a format string to printf that uses its own little language of format modifiers to tell printf the number and type of things you want to display. cout (usually) does the right thing by figuring out the number and types for you, so it's considered to be safer. Any sophisticated formatting with cout is extremely verbose compared to printf, but that's counter weighted by cout's flexibility. Provided you define the right member functions for your classes, you can use them with cout just like any other object that cout recognizes while it's not so simple with printf. cout, and iostreams in general, are bloated and slower than C-based I/O, but they're far more flexible.
My best code is written with the delete key.