My current homework is to compare execution times of the Boyer-Moore, Knuth-Morris-Pratt and Rabin-Karp algorithms.
Since the search is pretty fast I thought of using clock_gettime() so nanoseconds will be returned.
struct timespec *ts;
t = clock_gettime(CLOCK_REALTIME, ts);
printf("%d seconds and %ld nanoseconds\n", ts->tv_sec, ts->tv_nsec);
When I compile I get the message:
system_time.c:(.text+0x43): undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
I have included <time.h>, and checked for the existence of clock_gettime() there.
Sorry for double posting, I tried
gcc -lrt -o time time.c
and it worked.
It seems that some types needed for the call are located in librt