如何用C语言编写定时器程序?
发布网友
发布时间:2022-05-06 13:38
我来回答
共1个回答
热心网友
时间:2022-06-30 19:02
#include <stdio.h>
#include <time.h>
main()
{
clock_t start,end;
int n;
printf("How many seconds do you want to count? ");
scanf("%d",&n);
getchar();
clrscr();
start=end=clock();
while((n-(int)(end-start)/19)>=0&!kbhit())
{
printf("the time is: %d",n-(int)(end-start)/19);
sleep(1);
end=clock();
clrscr();
}
}