Why I have to cin.ignore() ?

This is a discussion on Why I have to cin.ignore() ? within the C++ Programming forums, part of the General Programming Boards category; Again, see "Flushing" the input stream...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,627
    Quote Originally Posted by Elysia View Post
    I think you're making mountans out of molehills right now.

    Prelude's articles tend to be complete. I don't think that means input is an insurmountable problem. A lot of detail goes into working with wide streams, and fixing other weirdness such as what happens if there is no input waiting in the stream when you ignore. These details are not relevant all of the time. I could plan my input so that such special cases never occur.

    Additionally, I would handle EOF all of the time, sure, but that's well defined in the standard.

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    I merely pointed out that it's not always so "simple," to just put some cin.ignore() statements in well defined points in the code, as the article seems to indicate.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #19
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Quote Originally Posted by Elysia View Post
    I merely pointed out that it's not always so "simple," to just put some cin.ignore() statements in well defined points in the code, as the article seems to indicate.
    That was initially my point anyway !
    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 !



  5. #20
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,627
    And you turned my simple correction into a debate. I didn't have any problem with what you said other than what I quoted. Fixing the stream state is easy, after which you'd call some version of ignore_line() from the article. After reading the article, of course.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cin.ignore();
    By BlackSlash12 in forum C++ Programming
    Replies: 7
    Last Post: 08-24-2007, 02:20 PM
  2. cin.ignore() in C
    By swgh in forum C Programming
    Replies: 10
    Last Post: 08-09-2007, 10:45 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