Thread: Simple cin clarification

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    86

    Simple cin clarification

    What are the differences and similarites between
    Code:
    cin>>charx;
    and
    Code:
    cin.get(charx);
    Thanks in advance!

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    What do you think is the difference? By the way the second snippet is wrong, you should be passing the address of the character.


    Jim

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jimblumberg
    By the way the second snippet is wrong, you should be passing the address of the character.
    No, it is correct, assuming that charx is a char, since the corresponding parameter is a reference to char.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Right, don't know what I was thinking.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple loop clarification
    By figarojones in forum C Programming
    Replies: 2
    Last Post: 12-10-2012, 04:04 AM
  2. Very simple clarification about strings (I hope).
    By figarojones in forum C Programming
    Replies: 3
    Last Post: 11-12-2012, 04:42 PM
  3. Clarification....
    By CommonTater in forum C Programming
    Replies: 4
    Last Post: 09-23-2010, 05:39 PM
  4. Help! Need some clarification.
    By jaro in forum C Programming
    Replies: 2
    Last Post: 04-08-2006, 11:44 AM
  5. Need a clarification here
    By bithub in forum A Brief History of Cprogramming.com
    Replies: 30
    Last Post: 12-27-2004, 01:06 AM