Home > Back-end >  C implementation using system time accurate timing
C implementation using system time accurate timing

Time:09-16

In c + + calculated according to the clock timing, just run through the program available to timing, sometimes is not accurate, so, according to the system time can by adding headers Windows. H time, the effect is good

CodePudding user response:

#include#include


using namespace std;

Int main ()
{
Int flag=0;
SYSTEMTIME sys.
Int time=0;
Int init_time=0;

For (;; )
{

GetLocalTime (& amp; Sys);

If (init_time==sys. WSecond & amp; & Flag==0)
{
}
The else
{
flag=1;
If (init_time==sys. WSecond & amp; & Flag==1)
{
Init_time=sys. WSecond;
Time++;
flag=0;
}
Init_time=sys. WSecond;
}

If (time==11)
{
Time=0;
Init_time=0;
}
Cout & lt; <"Time:" & lt;
  • Related