Hey guys. I just created a word game with a countdown timer but the problem is the timer wont start automatically. You have to press any button for to start. Can you please help me with these? Here's my code for the timer.
Code:
#include<stdio.h>
#include<time.h>
#include<conio.h>
void wait (int sec)
{
clock_t end_wait;
end_wait=clock() + sec *CLK_TCK;
while (clock()<end_wait){}
}
int main (void)
{
int hours, seconds=10, s;
time_t t;
struct tm *tm;
tm=localtime(&t);
s=seconds;
while(seconds>=0){
tm->tm_sec=s;
tm->tm_hour=s/3600;
tm->tm_min=s/60;
mktime(tm);
printf("%02d:%02d\n", tm->tm_min, tm->tm_sec);
s--;
seconds--;
wait(1);
if (tm->tm_sec==0)
{
printf("GAME OVER. PLEASE TRY AGAIN");
}
return 0;
}