delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/03/04/06:30:16

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <40470F8C.AA25BECD@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What is portable equivalent of getch()?
References: <c270na$1jhh$1 AT alpha2 DOT radio-msu DOT net>
Lines: 22
Date: Thu, 04 Mar 2004 11:15:45 GMT
NNTP-Posting-Host: 12.76.139.86
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1078398945 12.76.139.86 (Thu, 04 Mar 2004 11:15:45 GMT)
NNTP-Posting-Date: Thu, 04 Mar 2004 11:15:45 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Anthony wrote:
> 
> What construction should I use instead of getch() (just to wait
> for keypress) to make code portable?

You can wait for an ENTER (cr) keypress, with something like:

   int flushln(FILE *f)
   {
      int ch;

      while ((EOF != (ch = getc(f)) && ('\n' != ch)) continue;
      return ch;
   } /* flushln */

which is capable of detecting EOF.

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT worldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!

- Raw text -


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