|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
||||
|
||||
|
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.
|
|
#5
|
|||
|
|||
|
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("") |
|
#6
|
||||
|
||||
|
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) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Difference Between Cout and Printf? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|