我想编写一个程序,让用户在特定时间段内猜测一个数字。如果他未能在时间段内猜出正确的数字,则会发生超时,游戏将从第一个开始。
喜欢
main() {
int i, timer;
while(1) {
/* How to run the timer independently and it will signal that time out !!!*/
for(i = 0; i <= 10; i++) {
printf("\n Guess the value of i : ");
scanf("%d", &j);
if(i != j) {
printf("Bad Luck wrong Guess ");
}
else
printf("Great, You guessed correctly \n");
}
}
}
在这个程序中,我只是不知道在哪里运行计时器以及如何运行?请帮我。