Topic: reading a single character using C++ libary


Author: Dietmar Kuehl <dietmar.kuehl@claas-solutions.de>
Date: 2000/02/24
Raw View
Hi,
In article <88r2vh$e8m$1@nntp5.atl.mindspring.net>,
  "Steven Hodgen" <shodgen@mindspring.com> wrote:
> Is there a "approved" way to read a single character,

Sure. Here are a few examples:
- in.get();
- char c; in >> std::noskipws >> c;
- in.rdbuf()->sbumpc();

> for choosing menu items, etc., using C++ streams?

This kind of indicates that you don't want to press the return key
after pushing the key for the selection. Well, this is actually not a
C++ but rather an operating system issue: Some operating systems buffer
the keyboard characters by default until the return key is pressed.
There are actually some systems where it is impossible to turn this
buffering off. However, the C++ does not require an implementation to
support any way to read characters immediately (actually, it does not
require much for 'std::cin' at all). Thus, you have to use some
environment specific approach to address this problem. I think the FAQ
of comp.lang.c talks about this problem. The most portable solution to
this problem isprobably using curses or ncurses.
--
<mailto:dietmar.kuehl@claas-solutions.de>
homepage: <http://www.informatik.uni-konstanz.de/~kuehl>


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ 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: "Steven Hodgen" <shodgen@mindspring.com>
Date: 2000/02/22
Raw View
Hi,

Is there a "approved" way to read a single character, for choosing menu
items, etc., using C++ streams?  The docs that come with MSDN don't give up
this answer easily.

Thanks,
--Steven



---
[ 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              ]