Exforsys
+ Reply to Thread
Results 1 to 3 of 3

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?...

  1. #1
    Happy Harry is offline Junior Member Array
    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?


  2. #2
    Limca is offline Junior Member Array
    Join Date
    Apr 2006
    Answers
    21
    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.


  3. #3
    Sandhya.Kishannag is offline Member Array
    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



Latest Article

Network Security Risk Assessment and Measurement

Read More...