The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Difference Between Cout and Printf?
Discuss Difference Between Cout and Printf? in the C Programming forum on Dev Shed. Difference Between Cout and Printf? C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 30th, 2002, 02:46 PM
|
|
Contributing User
|
|
Join Date: Jun 2002
Posts: 36
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
|
Difference Between Cout and Printf?
Hi everyone,
Im new to this forum and kind of new to C++ but i was wondering if there was a "Big" difference between using cout or printf. I allready tried searching with the search button but didnt find a thread about it. Thanks.
-Optix
|

July 1st, 2002, 10:24 AM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
cout is an object of the iostream in C++. If you are using C++, then use cout, it works well.
printf while doing some the same things, it is a formatting function that prints to the standard out. This is mainly used in C
|

July 1st, 2002, 12:22 PM
|
 |
Mobbing Gangster
|
|
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
|
|
|
On the sidenote, since printf also does extra things there is overhead in speed of using it instead of cout, which simply outputs info.
__________________
And you know I mean that.
|

July 1st, 2002, 01:20 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
One more difference is that printf returns an integer value (the number of characters actually printed) and cout does not return anything. Believe it or not, this comes in handy sometimes, especially when you're trying to format your text into columns.
|

July 1st, 2002, 05:12 PM
|
|
Contributing User
|
|
Join Date: Jun 2002
Posts: 36
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
|
thanks for your replys
Yea its just in that all my books i have it uses cout but in most prgs i see on pscode.com or anywhere else use printf("")
|

July 1st, 2002, 06:30 PM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
The thing is, that C is still a dominant force in programming, and a lot of C programmer that program in C++ intermix C and C++. Although there are a lot of replacements for functions that are the standard way of doing thing with C in C++ it is still common to see C syntax in C++ programs because that is what most C programmers are comfortable with. It is just a preference.
This is still mainly a console/non-gui application style of programming. Most of the output in gui style applications use neither of these methods. (Although you might see quite a bit of sprintf)
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|