Home > Back-end >  C language while the output
C language while the output

Time:10-26

How to let the while the output of the time interval between

CodePudding user response:

While (nIf (n %==0 100000) output {}
N++
}

CodePudding user response:

Sleep () function

CodePudding user response:

 # include & lt; stdio.h> 
# include & lt; Windows. H>

Int main (void)
{
Int nDelayTime=0;
While (1)
{
NDelayTime++;
If (nDelayTime==1000)
{
NDelayTime=0;
Printf (" hello world \ n ");
}
Sleep (1);
}
return 0;
}

Each time delay 1 ms, accumulate 1000 times, that is, 1 s, doing so will not affect other parts

CodePudding user response:

Certainly, you this is single threaded

CodePudding user response:

Under Linux use sleep ()/usleep (); Under Windows can use the Sleep ()

Pay attention to the parameters of meaning may be different, as some seconds, have a plenty of milliseconds
  • Related