Answers for "how to print time function in milliseconds in c"

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 "how to print time function in milliseconds in c"

Code answers related to "C"

Browse Popular Code Answers by Language