This is not a homework, it's more of a challenge from our prof but I'll be tagging it as one nonetheless.
The problem is to create a typing game that has 3 levels with matching difficulty, different time limits (in seconds) and scores. Now I don't have any problems with the program itself, what I'm having problem is implementing the timer, that should be OS independent (I assume, since the only hint says it's time.h ). What I did is wrong, for it's only a rough guess from what I read about the time.h, it's also ugly code:
time_t start;
int timer = time(&start);
...
time_t current;
for(ctr=0;ctr<10;ctr++)
{
...
if(time(¤t) == (timer+40))
{
break;
}
...
}
Works sometimes but doesn't most of the time since it's only a rough guess. Any suggestions would be appreciated.