Date: Wed, 9 Sep 1998 19:31:12 +0300 (IDT) From: Eli Zaretskii To: loki cc: djgpp AT delorie DOT com Subject: Re: problems reading from keyboard In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On 9 Sep 1998, loki wrote: > while (c=getkey() != 'q') { > printf("%d\n",c); fflush(stdout); > } > > Now, the strange thing is that all this prints out is 1's You forgot about the operator precedence: != binds *before* =, so the code generated by the above first calls `getkey', then compares the return value to `q', and *then* assigns the result of this comparison (1 or 0, depending on what you have read) to `c'. You should write it thusly: while ((c=getkey()) != 'q') { and then it will do what you want. Btw, compiling with -Wall switch should cause the compiler to emit a warning for that line. You should always use -Wall, IMHO.