Thread: what is cin?

  1. #1
    gilad
    Guest

    Question what is cin?

    hello
    i started to learn in this site and i don't understend what is the commend cin please help me

  2. #2
    Unregistered
    Guest
    Inreasonably practical terms cin is the "command" to take information from the standard input source (usually the keyboard), store the information in a designated section of memory (the variable you specify), and (usually) display the information on the standard display source (usually the monitor screen). In a more technical sphere it is a predeclared global instance of the istream class, but there is no reason to get technical at your stage of the game.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Inreasonably practical terms cin is the "command" to take information from the standard input source (usually the keyboard), store the information in a designated section of memory (the variable you specify), and (usually) display the information on the standard display source (usually the monitor screen). In a more technical sphere it is a predeclared global instance of the istream class, but there is no reason to get technical at your stage of the game.
    More specifically, cin is a function which exploits two major C++ mechanisms:
    1) Overloaded operator.
    So you don't have to do 'cin(input);', instead you do 'cin >> input;'
    2) Overloaded parameters.
    'cin' is actually several functions, each written to accept a given datatype( one for int's, one for char*, etc, etc.

    cin does NOT display to the moniter. This is handled by the operating sytem thru the keyboard...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    More specifically, cin is a function
    No it isn't. cin is an object. As has already been said it is a predeclared instance of istream.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    It's an input stream.
    I always called it console in (cin).
    Then it's opposite console out (cout).
    That keeps things simple.

  6. #6
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    its an input stream, it is a predefined instance of an object and if i remember correctly it is also buffered.
    Monday - what a way to spend a seventh of your life

  7. #7
    Registered User
    Join Date
    Mar 2011
    Posts
    1
    Thank guy now can i get an example on how to use the cin command

  8. #8
    Registered User
    Join Date
    Mar 2011
    Posts
    69
    Quote Originally Posted by Sixolile View Post
    Thank guy now can i get an example on how to use the cin command
    Code:
    cout << "How old are you?\n";
    int age;
    cin >> age;
    cout << "Ok, now i know you are " << age << " years old." << endl;
    Now in age variable you have value you entered in console.
    Last edited by kargo; 03-07-2011 at 12:10 PM.

  9. #9
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    I'm losing it! Is the year 2002?
    Devoted my life to programming...

  10. #10
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    733
    Quote Originally Posted by Sixolile View Post
    Thank guy now can i get an example on how to use the cin command
    Now, after 9 years of trying to understand what the 'cin' command is, he/she wants an example. I'm wondering if in the next 9 years he/she will come back asking about cout. Good luck anyway.

  11. #11
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Closed. Please dont bump old threads

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin problem
    By mikahell in forum C++ Programming
    Replies: 12
    Last Post: 08-22-2006, 11:14 AM
  2. Check if a cin is null
    By HumbuckeR in forum C++ Programming
    Replies: 6
    Last Post: 04-16-2006, 08:16 AM
  3. cin not allowing input after first use of function
    By Peter5897 in forum C++ Programming
    Replies: 5
    Last Post: 01-31-2006, 06:29 PM
  4. Overriding Cin with Cout
    By Tainted in forum C++ Programming
    Replies: 5
    Last Post: 10-06-2005, 02:57 PM
  5. multiple instances of cin
    By Chaplin27 in forum C++ Programming
    Replies: 4
    Last Post: 10-08-2004, 04:51 PM