www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/09/05:21:31

Message-ID: <3A5AE4E7.85120936@student.uni-ulm.de>
Date: Tue, 09 Jan 2001 11:16:07 +0100
From: Karsten Schmidt <Karsten DOT Schmidt AT student DOT uni-ulm DOT de>
Organization: =?iso-8859-1?Q?Universit=E4t?= Ulm
X-Mailer: Mozilla 4.75 [de] (Win98; U)
X-Accept-Language: de
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with kbhit()
NNTP-Posting-Host: pcks.e-technik.uni-ulm.de
X-Trace: 9 Jan 2001 11:15:52 +0100, pcks.e-technik.uni-ulm.de
Lines: 36
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi!

I'm trying to detect when the user hits the keyboard. 
Unfortunately the kbhit() function is always true 
after the first key has been hit. Therefore I'm not able to
detect any further hits.


I've tracked down my problem to the following program:

#include <stdio.h>
#include <stdlib.h>
#include <pc.h>                     
#include <dos.h>

int main (void)
{  while(!kbhit())    // Wait until key pressed
   {  printf(".");
      delay(1000); }
   printf("\n");
   while (kbhit())    // Wait until key released
   {  printf("+");
      delay(1000);}
   exit(0);
}

As you coud see the program should exit after a key is pressed and
released.
But the programm is still running in the second loop.

Perhaps someone could help me with this problem.

Thanks in advance.

-- 
Karsten

- Raw text -


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