DEMO: Stopwatch utility

This commit is contained in:
kougyokugentou 2021-10-24 16:18:16 -07:00
parent ff415d0d93
commit 0e0f5e966a

50
demos/stopwatch2.c Normal file
View File

@ -0,0 +1,50 @@
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <pc.h>
void main(void)
{
int h, m, s, ms, col;
/* Init values */
h = 0;
m = 0;
s = 0;
ms = 0;
col = 0;
for(;;)
{
if(kbhit())
{
getch();
exit(0);
}
printf("%dh%dm%ds.%dms",h,m,s,ms);
if( (++col % 1) == 0) printf("\r");
ms++;
if(ms > 99)
{
ms = 0;
s++;
}
if(s > 59)
{
s = 0;
m++;
}
if(m > 59)
{
m = 0;
h++;
}
delay(100);
}
}