
- Forum
- Programming Talk
- C and C++
- what is the diffrence between cout and puts?
what is the diffrence between cout and puts?
This is a discussion on what is the diffrence between cout and puts? within the C and C++ forums, part of the Programming Talk category; someone could help me with the difference between cout and puts gives the same output.what is the diffrence?...
-
11-08-2006, 12:09 AM #1
- Join Date
- Feb 2006
- Answers
- 12
what is the diffrence between cout and puts?
someone could help me with the difference between cout and puts gives the same output.what is the diffrence?
-
1 - puts is an ANSI C function defined in the <stdio.h> header
2 - cout is not a function: it's a stream, associated to a file. When you do something like:
cout << "Hello" << endl;
You are using operator << (operator 'send to', which is a function, but written in C++, so unlike puts, it's Object-Oriented) : you are sending the string "Hello" to the stream cout, which is analogous to C's stdout.
3 - Same for getline and cin, except that getline is redefined in C++'s <iostream> header, so you need to be careful.
-
03-12-2012, 01:13 PM #3
- Join Date
- Feb 2012
- Answers
- 66
Prototype: int puts(const char *astring);
Puts is a function which will output the string pointed to by astring. It will then add a newline character. This is built in to the function. It returns a nonnegative integer if it was successful. It returns EOF if there was an error.
cout is an object of the std:
stream class.It has many manipulators that allow specific formatting of output.
-
Sponsored Ads
«
Help! pls!
|
Best Alternative
»

Reply With Quote





