How to make an alarm clock!?

Okay so I figured out how to get time in c++ but after that I dont know how to countdown to the desired time that the user set and maybe say "the alarm has gone off" ..I dont know where to go from here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <ctime>
#include <iomanip>

using namespace std;

char dateStr [9];
char timeStr [9];
char almtimestr[9];

int main(){

_strtime( timeStr);
_strtime( almtimestr);

int consoleWidth=70;
cout<<setw(consoleWidth / 2)<<" "<<"The current time is: "<<timeStr<<endl;
cout<<setw(consoleWidth / 2)<<" "<<endl;
cout<<setw(consoleWidth / 2)<<" "<<"Pls format time as utc"<<endl;
cin >> almtimestr;
//after this I have no idea how to countdown to the desired time say 3:00 pm!!
}


How to check if the time is up or do I count down I have no clue!!
I just needed some instructions and Imma right but can someone pls give me an example of this timing thing !! PLSS I am desperate right now and this is due for tomorow!
Last edited on
You don't have to count down. Just check the time every minute, if the hours and minutes are equal to the alarm time, start the event of the alarm.
how do I check I dont understand??
is like an if or while statement or something to check SOMEONE HELP!!
There are sleep functions available everywhere. Find one, and make your program sleep for a minute. You may use a while loop, but that's bad because it keeps your processor busy all the time.

Find a sleep function, that'll do it.
Topic archived. No new replies allowed.