#include<conio.h>
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
int GetHour(char *s)
{
char *p, *q;
p = (char *)malloc(10);
strcpy(p, s);
q = p;
while(*q != ':')
{
q++;
}
*q = '\0';
return atoi(p);
}
int GetMinute(char *s)
{
char *p;
p = (char *)malloc(10);
strcpy(p, s);
while(*p != ':')
{
p++;
}
p++;
return atoi(p);
}
main()
{
char s[10];
int hour,minute;
time_t t;
struct tm *timeinfo;
printf("please input the time like [18:30]:\n");
gets(s);
hour = GetHour(s);
minute = GetMinute(s);
while(1)
{
time(&t);
timeinfo = localtime(&t);
if(timeinfo->tm_hour < hour)continue;
else if(timeinfo->tm_min < minute)continue;
else
{
printf("Time is up!Wake up!\n\007");
printf("\a\a\a\a");
exit(0);
}
}
}