DEMO: Stopwatch utility
This commit is contained in:
parent
ff415d0d93
commit
0e0f5e966a
50
demos/stopwatch2.c
Normal file
50
demos/stopwatch2.c
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user