Topic: Read character from the keyboard


Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1998/04/09
Raw View
In article 3823@couriernet.infi.net, Gruny <gruny@couriernet.infi.net> writes:
>Hello folks,
>
>I am looking for an easy way to read a character in C++ from the
>keyboard,
>such that if a character is not available then the program continues
>without waiting.

No such capability is provided in standard C or C++. That is,
neither C nor C++ has the notion of a keyboard, nor do they
have the notion of non-blocking I/O.

Operating systems usually have the capability, and a C++ implementation
will usually document how to access the O/S functionality.

For a discussion of this issue, see the FAQ for comp.lang.c, or
the book "C Programming FAQs", by Steve Summit, Addison-Wesley.

---
Steve Clamage, stephen.clamage@sun.com
---
[ 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: Gruny <gruny@couriernet.infi.net>
Date: 1998/04/07
Raw View
Hello folks,

I am looking for an easy way to read a character in C++ from the
keyboard,
such that if a character is not available then the program continues
without waiting.

At present, I know I could use a fork() or some form of XMotif callback.
However, I would like to believe that the iostream supports this and
that I
have just over looked it.

Thanks In Advance,

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