Topic: Problem with enter Key


Author: brahms@mindspring.com (Stan Brown)
Date: 1999/08/23
Raw View
andreasm@darmstadt.gmd.de (Andreas Mueller) wrote in comp.std.c++:
>I want to wait sometimes till a user presses the Return-Key, so I wrote
>a method to wait for Return. This works fine, but the very first time I
>call this method I have to press enter twice to get one result. I use
>std::cin included from <iostream> in vc 5.0.

It's a known bug, but unlike most of them this one actually has a known
fix. See the Dinkumware site at http://www.dinkumware.com/support.html .

--
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA
                                    http://www.mindspring.com/~brahms/
I don't need e-mail copies of posted follow-ups, but if you send
them PLEASE identify them as such.
My reply address is correct as is. The courtesy of providing a correct
reply address is more important to me than time spent deleting spam.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Andreas Mueller <andreasm@darmstadt.gmd.de>
Date: 1999/08/19
Raw View
Hi all,

I want to wait sometimes till a user presses the Return-Key, so I wrote
a method to wait for Return. This works fine, but the very first time I
call this method I have to press enter twice to get one result. I use
std::cin included from <iostream> in vc 5.0.

source:

  char *c=new char[255];
  std::cout <<"\nplease hit enter.";// this appears only once - but I
have to hit 'ENTER' twice - but only the very first time?!?
  std::cout.flush();

  std::cin.getline(c,255);
  delete [] c;

tia
    Andreas

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]