用C语言怎么编辑一个闹钟?
1个回答
展开全部
呵呵,写了一个玩玩:
#include <stdio.h>
#include <windows.h>
#include <winbase.h>
int main(int argc, char *argv[])
{
SYSTEMTIME time;
SYSTEMTIME clock;
GetLocalTime(&time);
printf("当前时间为:%2d:%2d:%2d\n",time.wHour,time.wMinute,time.wSecond);
printf("请设定闹钟时间:\n");
printf("时:");
scanf("%2d",&clock.wHour);
printf("分:");
scanf("%2d",&clock.wMinute);
while(1)
{
Sleep(1000);
GetLocalTime(&time);
if((time.wHour==clock.wHour)&&(time.wMinute==clock.wMinute))
{
printf("\a\a\a时间到!!!");
break;
}
}
return 0;
}
#include <stdio.h>
#include <windows.h>
#include <winbase.h>
int main(int argc, char *argv[])
{
SYSTEMTIME time;
SYSTEMTIME clock;
GetLocalTime(&time);
printf("当前时间为:%2d:%2d:%2d\n",time.wHour,time.wMinute,time.wSecond);
printf("请设定闹钟时间:\n");
printf("时:");
scanf("%2d",&clock.wHour);
printf("分:");
scanf("%2d",&clock.wMinute);
while(1)
{
Sleep(1000);
GetLocalTime(&time);
if((time.wHour==clock.wHour)&&(time.wMinute==clock.wMinute))
{
printf("\a\a\a时间到!!!");
break;
}
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询