Answers for "c program to print time in milliseconds"

C
1

c get time in milliseconds

#include <sys/time.h>

long long current_timestamp() {
    struct timeval te; 
    gettimeofday(&te, NULL); // get current time
    long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // calculate milliseconds
    // printf("milliseconds: %lldn", milliseconds);
    return milliseconds;
}
Posted by: Guest on June-06-2021

Code answers related to "c program to print time in milliseconds"

Code answers related to "C"

Browse Popular Code Answers by Language