I want to set an internal timer of 30 seconds in c++.
within that user have to enter 3 inputs one after other. and for each input i want set one Parameter which will change for each input by user.
example user i/p parameter
1. abc 5
2. pqr 6
3. xyz 7
This should happen within 30 seconds. else error "Timeout".

Could you please help me.

After 30 Seconds Message of "Timer Expired" should Come

when user starts input timer should start and counts downward.

please help...........


You will probably need to create a function that checks for keyboard hit (such as kbhit() from conio.h) and time() to get current time, something like this. This won't work if your compiler does not support conio.h, which is a non-standard header with non-standard functions.

It also assumes MS-Windows os because of the Sleep function. If you are using *inux os then replace it with sleep() (lower-case 's')

bool chkinput()
   time_t t1, t2;
   t1 = time(0);
   while( !kbhit())
         t2 = kbhit();
         if( (t2-t1) >= 30)
            return true;
   return false;
This question has already been answered. Start a new discussion instead.