954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help me Dealing with the Loops in Stopwatch

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

Shardendu
Newbie Poster
19 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

done it.. :)

Shardendu
Newbie Poster
19 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

How did you do it?

NoctiS17
Newbie Poster
1 post since Mar 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: