Date: Sun, 22 Feb 1998 21:09:30 -0500 (EST) Message-Id: <199802230209.VAA23206@delorie.com> From: DJ Delorie To: spyder AT binary DOT net CC: djgpp AT delorie DOT com In-reply-to: (message from Daryl Johnson on Sun, 22 Feb 1998 19:35:56 -0600) Subject: Re: Need help with timer function Precedence: bulk > I am creating a program that administers a test to an individual. The test > is timed. The problem I am having is with getch(). Even when the timer has I think you want something like this (untested). This is similar to yours, but note the use of kbhit(), which tells you *if* a key has been hit. Note also the use of __dpmi_yield() to avoid using 100% of the CPU. You may want to look up getkey() and getxkey() as alternates to getch(), depending on your needs. #include #include #include #include int timed_getch(int seconds) { time_t start, end; time(&start); while (1) { time(&end_time); if (end_time - start_time > seconds) return -1; if (kbhit()) return getch(); __dpmi_yield(); } }