what does cin.ignore( ) mean?

This is a discussion on what does cin.ignore( ) mean? within the C++ Programming forums, part of the General Programming Boards category; Alright, I'm using Code::Blocks. So, what does cin.ignore() mean? I'm still learning C++ because I'm a beginner....

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    9

    what does cin.ignore( ) mean?

    Alright, I'm using Code::Blocks.

    So, what does cin.ignore() mean? I'm still learning C++ because I'm a beginner.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    2,304
    in cases like this, google is your friend, but I'll throw you a bone. C++ Reference

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    9
    Quote Originally Posted by Elkvis View Post
    in cases like this, google is your friend, but I'll throw you a bone. C++ Reference
    What do they mean of "Extract and discard characters"? It ignores strings/letter inputs?

  4. #4
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Conti View Post
    What do they mean of "Extract and discard characters"? It ignores strings/letter inputs?
    Sort of..
    Suppose the user enters a whole sentence ..and you 'get' only the first word.
    Using std::cin.ignore(LengthOfSentence, '\n') will remove the other words from the input buffer, until the newline ..so that the next time you use cin, they can't interfere.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin.ignore()
    By valthyx in forum C++ Programming
    Replies: 2
    Last Post: 07-22-2008, 04:23 AM
  2. cin.ignore();
    By BlackSlash12 in forum C++ Programming
    Replies: 7
    Last Post: 08-24-2007, 02:20 PM
  3. Console window waiting on cin.ignore() or cin.ignore(2)
    By The SharK in forum C++ Programming
    Replies: 3
    Last Post: 07-19-2006, 04:17 PM
  4. ignore
    By indigo0086 in forum C++ Programming
    Replies: 1
    Last Post: 11-13-2002, 08:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21