Good morning. I wrote the following code:
I try to get a random int but I always get the same value when I compile the program with gcc -g rand.c -o rand -lrtCode:#include <stdio.h> #include <stdlib.h> #include <time.h> struct timespec ts; int main() { int value; srand(clock_gettime(CLOCK_REALTIME, &ts)); value = rand(); printf("\nThe value: %d\n", value); return 0; }
The value: 1804289383
What am I doing wrong?
I already tried with CLOCK_MONOTONIC too.