Hi

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...........

Thanks
Mukesh:)

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())
   {
         Sleep(100);
         t2 = kbhit();
         if( (t2-t1) >= 30)
            return true;
   }
   return false;
}

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.