www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/09/11:39:58

Message-ID: <000301bddc08$160f6a40$18a531ce@enterprise-z>
From: "Jorge Ivan Meza Martinez" <jimeza AT usa DOT net>
To: "loki" <loki AT nectar DOT com DOT au-remove>, <djgpp AT delorie DOT com>
Subject: RE: problems reading from keyboard
Date: Wed, 9 Sep 1998 10:16:34 -0500
MIME-Version: 1.0

Hi,

your problem was so cute, see ...

>while (c=getkey() != 'q') {

the while is taking the getkey() return but is not asigning it to c,
you have to associate it before compare, consider something like,

>while ( ( c=getkey() ) != 'q') {
              ^    adding    ^

then you will be putting the getkey() return into c and then comparing with
'q';
it will work!.

Very interesting question.

       Jorge Ivan Meza Martinez
               jimeza AT usa DOT net
  jimezam AT armenia DOT multi DOT net DOT com
            jimeza.home.ml.org

-----Mensaje original-----
De: loki <loki AT nectar DOT com DOT au-remove>
Grupos de noticias: comp.os.msdos.djgpp
Para: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Fecha: Martes, 08 de Septiembre de 1998 11:39 p.m.
Asunto: problems reading from keyboard


>
>Hey all,
>
>  I seem to be having problems reading keys from the keyboard.  This is
>probably a really dumb question because I've missed something obvious, so
>bear with me.  Here's a snippet of code which shows my problem:
>
>int c;
>
>while (c=getkey() != 'q') {
> printf("%d\n",c); fflush(stdout);
>}
>
>  Now, the strange thing is that all this prints out is 1's; in other
words,
>I'm reading ASCII character 1 no matter what I press... yet pressing the Q
>key exits the program just fine.  What am I doing wrong or what am I
>forgetting?
>
>
>
>--
>       loki
>loki (at) nectar.com.au         http://puck.nether.net/~loki/
># Dare I disturb the universe?  You bet I do!
>

- Raw text -


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