function function: GetTickCount returns (retrieve) the number of milliseconds from the operating system boot to the current (elapsed), and its return value is DWORD.
Knowing this, this program is not a difficult thing ...
CODE:
Copy Code code as follows:
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <stdio.h>
typedef struct NODE
{
int h;
int m;
int s;
}
*ptime;
void sleep (long wait);
void GetTime ();
int main ()
{
Ptime times;
int flag = 1;
Char time[128];
Todo
{
_strtime (time); Gets the current system time (does not include the date)
System ("CLS"); Clear Screen
printf ("OS Time:%s\n", time);
GetTime (times); Call GetTime ()
Sleep (1000); Sleep 1 Second
printf ("Power-on time:%02d hours%02d minutes%02d seconds \ n", Times->h, Times->m, times->s);
}while (flag); Always cycle
return 0;
}
void sleep (long wait)
{
Long goal; Define Total time
Goal = wait + clock ();
while (Goal > Clock ());
}
Ptime gettime (ptime T)
{
int i = GetTickCount ();
T->h = (i/1000)/3600;
T->m = (i/1000)/60-t->h * 60;
T->s = (i/1000)-t->h * 3600-t->m * 60;
return T;
}