#include <sys/time.h> int main() { timespec ts; // clock_gettime(CLOCK_MONOTONIC, &ts); // Works on FreeBSD clock_gettime(CLOCK_REALTIME, &ts); // Works on Linux }
#include <sys/time.h>
int main() {
struct timespec ts; // Declare a variable 'ts' of type 'struct timespec'.
// clock_gettime(CLOCK_MONOTONIC, &ts);
// Uncomment the above line on FreeBSD to get the monotonic time.
clock_gettime(CLOCK_REALTIME, &ts);
// Get the current real-time clock time and store it in 'ts'.
}