X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Fausto Arinos Barbuto" Newsgroups: comp.os.msdos.djgpp Subject: Re: Function kbhit()? Date: Wed, 21 Jul 2004 09:27:03 -0600 Lines: 48 Message-ID: <2m7g9pFjkp4hU1@uni-berlin.de> References: <2m3hjoFibqajU1 AT uni-berlin DOT de> <7494-Tue20Jul2004073651+0300-eliz AT gnu DOT org> <2m3odtFhufc2U1 AT uni-berlin DOT de> <1438-Tue20Jul2004214057+0300-eliz AT gnu DOT org> X-Trace: news.uni-berlin.de 647avByJsM8fBZ1UNQQH5g3PgoQfQRPSDwcZK5nowKTY89BxMR X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Eli Zaretskii" wrote in message: > > From: "Fausto Arinos de A. Barbuto" > > Newsgroups: comp.os.msdos.djgpp > > Date: Mon, 19 Jul 2004 23:21:00 -0600 > > > > void check_event(int *key) > > { > > while (kbhit()) getch(); > > *key = bioskey(0); > > } > If this function is entered when a keypress is waiting in the BIOS > keyboard queue, then `getch' will eat up that keypress and `bioskey' > will wait until the next keypress and return that. Does this explain > the misbehavior you see (which you still didn't describe)? Hi Eli; Sorry, I was out of town yesterday. Let me explain what the misbehaviour is: the program, when executed, receives a numerical input (an interest rate) and after that (and here is the point where things get completely screwed) an input that will define whether the compounding period is annual or monthly. This is done by pressing either "A" or "a" for annual or, alternatively, "M" or "m" for monthly. No other input is accepted and the program doesn't go ahead until one of the four letters above is entered. It works beautifully with Borland C++, but not with GCC. What you say about getch() makes sense (I reckon), but things don't get any better if I remove it. I found a way to circumvent this problem by rewriting the piece of code where the compouding period is entered, identified and checked. But I am not happy with the solution I came up with. Firstly, because I'm still totally at sea as to why the code does not work with GCC. 2nd, because what was an otherwise very elegant function (check_event) has been replaced by seven ugly lines of code. Ah well. I guess I will never know what the problem is. Thanks for your help. ---Fausto