From: Sean Gilley Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro: reading input and comparing with switch Date: Fri, 21 Nov 1997 23:58:20 -0500 Organization: NetUnlimited, Inc. Lines: 30 Message-ID: <3476666C.35FE@netunlimited.net> References: <3474CB66 DOT BBF414A5 AT primenet DOT com> <6534h4$qu0$2 AT news DOT ox DOT ac DOT uk> NNTP-Posting-Host: uhura-26.netunlimited.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk George Foot wrote: > > On 20 Nov 1997 16:43:00 -0700 in comp.os.msdos.djgpp Mike McLean wrote: > > : I have functions that read in input using allegro's readkey command, and > : I have that character or letter checked by a switch statement. The > : Problem is sometimes it takes 2 or 3 times hitting the key to get it to > : read it. I'm stuck here. Please help me out. > > You're calling readkey twice! When you write: > > : readkey(); > : switch(readkey() & 0xff) > ... > > it calls readkey(), which waits for a key to be pressed, and discards > the value returned. Then it calls readkey() again, which waits for > another keypress, and uses that value to index the switch statement. > You need to get rid of the first readkey, perhaps. > > -- > george DOT foot AT merton DOT oxford DOT ac DOT uk ///////////////////////////////////////////////// Try char c; if(keypressed()) c=readkey();