Thread: cin >> something

  1. #1
    Registered User
    Join Date
    Jan 2008
    Location
    Malaysia
    Posts
    13

    cin >> something

    Can someone tell me why is it
    Code:
    cin >> something
    , where something is a variable, and not
    Code:
    cin << something
    ???

    Because, I got confuse with the cout object as cout uses the symbol <<. Thanks in advance

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The "arrow" created by ">>" or "<<" indicates which direction the data goes. So "cout << x" sends the value of x to the output, "cint >> x" takes the input and fills it into x.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Location
    Malaysia
    Posts
    13
    Quote Originally Posted by matsp View Post
    The "arrow" created by ">>" or "<<" indicates which direction the data goes. So "cout << x" sends the value of x to the output, "cint >> x" takes the input and fills it into x.

    --
    Mats
    OMG, matsp, you're a really good programmer and explainer (althought there is no such word in dictionary). I've finally understand =) THANKS!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin >> string // multiple lines
    By msshapira in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2009, 04:39 AM
  2. cin >>
    By TehClutchKiller in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2008, 02:28 AM
  3. if (cin >> a) {
    By manzoor in forum C++ Programming
    Replies: 1
    Last Post: 02-24-2008, 07:48 AM
  4. cin >> buf endless loop
    By cfriend in forum C++ Programming
    Replies: 2
    Last Post: 10-07-2005, 04:01 PM
  5. cin >> char[]
    By Luigi in forum C++ Programming
    Replies: 3
    Last Post: 04-04-2003, 01:33 PM