Search code examples
c++ctimermilliseconds

how to stop timer after a given millisecond in c


 #include <stdio.h>
#include <time.h>   
int main (void)
{
double diff = 0.0;
time_t start;
time_t stop;
time(&start);
print("Enter millisecond to stop"); 

so what is code should add to stop timer after given interval of timer


Solution

  • int seconds;
    scanf ("%d",&seconds);
    stop = 0;
    while (stop < start + seconds)
        time(&stop);