It is not a easy concept for beginners to attempt the reason is because it requires Multi-Threading and it is not a beginners topic. We can create a new thread using a function using the function CreateThread. MSDN Documentation:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx
then in that thread create a new thread with a infinite for loop: for(;;){}
then use WaitForSingleObject function and put it in a if() statement with a comparison to WAIT_TIMEOUT.
Follow?
I think not it is too complicated for you, trust me don't attempt it yet it will only confuse you and get you tangled up.
Don't worry about it now. Well what I told you is more of a advanced way just to scare you away from this becuase doing this type of programs at this stage is not good.
int key()
{
switch()
{
//check key pressed
casecasecase
}
return // key pressed or nothing when none
}
main()
{
while (1)
{
if (key() == smth) // if key is pressed, do something
{
switch
{
do something
}
}
check_time // time checking should be so fast, that user wouldnt notice
if () // if time's up do something else
}
}