delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/03/04/09:15:27

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What is portable equivalent of getch()?
Date: 4 Mar 2004 14:03:07 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 21
Message-ID: <c27cur$g7b$2@nets3.rz.RWTH-Aachen.DE>
References: <c270na$1jhh$1 AT alpha2 DOT radio-msu DOT net>
NNTP-Posting-Host: ac3b07.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1078408987 16619 137.226.33.205 (4 Mar 2004 14:03:07 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 4 Mar 2004 14:03:07 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Anthony <akantsel AT integra DOT rmt DOT ru> wrote:
> Hello,
> What construction should I use instead of getch() (just to wait for
> keypress) to make code portable?

Ultimately, there is no such thing.  For starters, the world of
portable C includes platforms that don't even have a "keyboard" for
starters, much less a "screen" keypresses would usually be echoed to.

Keep in mind that there *might* be C programs running both _inside_
your mouse and _inside_ your keyboard.  Your toaster might be
controlled by a C program, and your microwave and washing machine
rather probably are, these days.

About the most portable way available to simulate a getch() would be
to use a 'curses' library, like ncurses or pdcurses.  Curses will hide
the unportable aspect from your own program.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019