do while loop clock

Hello everybody :D
I've written a C++ program that can act like a clock. You enter the time in hour, minutes and seconds in the 24 hour format and it ticks down the clock. I've done it using a do-while loop. Is it possible to make it run until the user types any key ? I've set it to run for an arbitrary 1000 seconds. I'm running on Ubuntu.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<iostream>
#include <time.h>
#include<stdlib.h>
void sleep(unsigned int mseconds)
{
    clock_t goal = mseconds + clock();
    while (goal > clock());
}
using namespace std;
int main()
{
    int Hour,Minute,second,i=1;

        cout<<"Enter the hour : ";
        cin>>Hour;
        cout<<"Enter the minute : ";
        cin>>Minute;
        cout<<"Enter the second : ";
        cin>>second;
        do
        {
        cout<<"The time is "<<Hour<<":"<<Minute<<":"<<second<<endl;
        sleep(1000000);
        system("clear");
        second++;
        if (second>59)
        {
            Minute++;
            second=second-60;
        }
        if (Minute>59)
        {
            Hour++;
            Minute=Minute-60;
        }
        if (Hour>23)
        {
            Hour=Hour-24;
        }
        i++;
    }while(i<1000);
}
Topic archived. No new replies allowed.