I was told to make a stopwatch program..but i am unable to figure out how to take come out of loop and pause it and again go back into the loop if resumed ( i tried the pause button on the keyboard and it works) but i have to take a particular key by myself. And if the timer reaches the time mentioned by user it would give a beep (i would do this by my own) Please help me with the Pause,Stop and Reset options or any way to come out of the loop and take input from user without disturbing the stopwatch.

Or if you can tell me how to use time.h header as my teacher haven't told me about this and also i cant find out any fully explained stuff on Internet.
Here's my little piece of silly code..

#include<iostream.h>
#include<conio.h>
#include<windows.h>
//define class
class timer
{
      int hh, mm, ss, n;    //private decl.
      public:
             //constructer
             timer()
             {
                    cout<<"Press Any Key to Start\nPress the Pause button to pause\nTo Stop Press (i didn't did it till)\n\n";
                    getch();
                    for(hh=0; hh<=100; hh++)                              //loop for hours
                    {
                              for(mm=0; mm<=60; mm++)                     //loop for minutes
                              {
                                      for(ss=0; ss<=60; ss++)             //loop for seconds
                                      { 
                                                cout<<"   hh:mm:ss";       
                                                cout<<"   "<<hh<<":"<<mm<<":"<<ss<<"\r";
                                                Sleep(1000);              //delay timer by 1 sec
                                      }        
                              }
                    }       
             }
};
int main(void)
{
      timer stop;
      getch();
}

Please help..I will be very thankfull.. :)

done it.. :)

How did you do it?

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.