Re: [OT] C++ codong problem

From: Joshua Hudson (joshudson@hotmail.com)
Date: Tue Jul 24 2001 - 18:15:57 CEST


From: Serge Skorokhodov <usia@operamail.com>

Hi everybody,

VPP> I would like to read a character from keyboard as it is
VPP> pressed for my menu system, but I havenät found a way to do
VPP> it, every function that I have found has to wait until enter
VPP> is pressed so send the buffer to my program. If there is a
VPP> way, please tell me.

> Try add a line like this in the beginnig of you C++ file:
>
> #include <conio.h>
>
> and use the function you can find there. Just look:
>
> while ( !kbhit() )
> {
> do_something_very_meaningful();
> do_something_even_more_meaningful();
> }
>
> The loop will be ended up as soon as a key pressed on the
> keyboard.
>
> The only bad news is that conio.h may not be available for some
> shells:( I'm not *nix programming expert though, but I guess
> conio.h is quite POSIX...

>It seems that I gave a bad advice:( as conio.h doesn't seem to be
>portable to *nixes:( Unfortunately, I only have a w2k machine at
>hand right now and I've look through Borland C++ help. Any
>console input/output routines portable to UNIX shell I've found
>require ENTER be pressed before the buffer becomes available for
>application:( The only thing I can think about right now in
>ncurses library but I hardly know any details:( Sorry for
>misleading message.

The C FILE* streams can be tweaked to provide such.
Try something like this:

stdin->flags &= _F_UNBUF

You may have to look into stdio.h to get the actual names.
This is from K&R C.

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

---------------------------------------------------------------------
To unsubscribe, e-mail: mulinux-unsubscribe@sunsite.dk
For additional commands, e-mail: mulinux-help@sunsite.dk



This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:19 CET