Alarm clock program

So this is what i've made so far. i call it Alarm Clock v 0.1.
Of course it just the beginning.
Problems I've encountered so far:
1)it does not change the time in console eg. 20:44:33 and this time will stay like this, seconds minutes etc. will not increase so i do it manualy
2)And because of upper problem if you launch the app when its 20:44:33
and spend 7 seconds entering the time you want to set the alarm it will still start at 20:44:33.
So any suggestions would be welcome :);

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
  int month, hour, minute,sec;
     // get current time
    time_t alarm = time(0);
    // convert to 'broken time'
    tm clock = *localtime(&alarm);

    cout<<"Enter the month (number), hour and minutes"<<endl;
    cin>>hour>>minute;



    for(int i=0; i<5000; i++)
    {
        system("cls");
        cout<<clock.tm_hour<<" : "<<clock.tm_min<<" : "<<clock.tm_sec++;
        if(clock.tm_sec==60) //nulls the secs and adds minutes
        {
            clock.tm_sec=1;
            clock.tm_min++;
        }
        if(clock.tm_min==60)
        {
            clock.tm_min=0;
            clock.tm_hour++;
        }
        if(clock.tm_hour==hour && clock.tm_min==minute && clock.tm_sec==sec)
           {
               system("temp.mp3");// plays the sound
               break;
           }

       _sleep(1000);

    }
Last edited on
Topic archived. No new replies allowed.