|
From: Stein N. <tem...@of...> - 2001-01-19 07:09:59
|
Try this; :-)
1)
#include <stdio.h>
#include <conio.h>
#include <time.h>
void get_answer(void)
{
clock_t start, end;
start = clock(); /*Start the timer*/
while(!kbhit()) /*While no one presses a
key*/
{
end = clock(); /*Get the new time*/
if((end-start)/CLK_TCK >= 5) /*Max time for question-answer is
5seconds*/
{
printf("Out of time!"); /*Some
out-of-time-message*/
return; /*Exit the
answer-function*/
}
}
if(getch() == '1') /*If the right answer
should be key 1 pressed*/
printf("YES, that's the right answer!");
else /*If key different
from '1' is pressed*/
printf("NO, that's not it!");
}
2)
#include <dos.h>
void main(void)
{
sound(440); /*Play a sound with frequency 440*/
delay(1000); /*Wait 1 second*/
nosound(); /*Stop playing sound*/
}
Mail if something does'nt work!... hope it does! :)
----- Original Message -----
From: "Ian Weston" <lak...@ho...>
To: <dev...@li...>
Sent: Wednesday, January 17, 2001 10:02 AM
Subject: [Dev-C++] Timing
> hi there, i've got two questions if someone could answer them for me.
>
> does anyone know:
> 1) how to do a function that only gives a limited time for you to
> answer a question?
>
> 2) how to produce a tone through the pc's internal speaker?
>
> it would be much appreciated if anyone could shed some light on this.
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
-------------
#define stone
|