473,506 Members | 16,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

diff between cout and puts

14 New Member
Please someone could guide me with the difference between cin,gets,getline and cout,puts,write.Especially cout and puts gives the same output then how are they different?????
Nov 6 '06 #1
1 8536
dariophoenix
34 New Member
Please someone could guide me with the difference between cin,gets,getline and cout,puts,write.Especially cout and puts gives the same output then how are they different?????

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.

If you need to do basic I/O in C++, check this site, I found it very useful:

www.cppreference.com
Nov 6 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

19
1501
by: qazmlp | last post by:
I hope comp.lang.c will not find the following question as a complete off-topic. I would like to remove ie.comment out the 'cout' statements during compilation(actually preprocessing) time. ...
6
21045
by: Omid | last post by:
Hi. I have problems when I try to redirect everything that is sent to cout to a file. I have one piece of code that works and one that does not work. The only difference is which headers I use....
9
1892
by: jlopes | last post by:
There seems to bet no diff between a vitual method and an inheirited method. class A_Base { public: virtual void filter(){ /* some code */ } }; class D_of_A_Base : public A_Base {
4
2341
by: Eric Boutin | last post by:
Hi all ! I'm currently writing a function that evaluate if there is a diffence beetween 2 streams (istringstream and ifstream). The problem is, it doesn't work. It *always* finds a difference...
3
1512
by: Radde | last post by:
HI all, What are the major diff betweeb refernce and pointer in C++.. Cheers...
9
6501
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
4
4934
by: Andreas Kasparek | last post by:
Hola! I'm preparing my master thesis about a XML Merge Tool implementation and was wondering if there is any open standard for XML diff regarding topics like: - is a diff result computed on...
4
6992
by: Penn | last post by:
Hello, I'm new to C++ and while I was playing around with one of my ideas I stumbled uppon the error message I used as a subject for this topic. My question to you out there is how can i make this...
4
1826
by: mail.dsp | last post by:
Suppose in a class we overload four operators: operator new operator delete operator new operator delete class Test{ public: void * operator new (size_t t){ cout<<"\nCalling... new";
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.