程序到整点会输出信息,不到整点什么都不做。
#include <time.h>
#include <stdio.h>
//#include <windows.h>
#include <unistd.h>
int main()
{
time_t t,now=time(NULL)/3600
while(1){
t=time(NULL)/3600
if(t==now){
//Sleep(1000)
sleep(1)
}
else{
printf("time: %d\n", t%24)
now = t
}
}
return 0
}
#include <windows.h>#include <time.h>
int main(void)
{
struct tm *aa
time_t tt
time(&tt)
aa=localtime(&tt)
while(1)
{
if(aa->tm_min==0) //如果是整点,分钟为0
Beep(800,800)
Sleep(60000)//每分钟检查一次
}
return 0
}