Using srand y rand in C

This semester I need to do code something using C and I don't remember much, I needed to generate random numbers and we know that "Random" isn't random at all in C, using rand() the numbers are going to repeat but using srand() we can get true random numbers, basically we need to change the "seed" inside the rand() using srand(), for this I'm going to use the time. I tested this code on Debian.

Code


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main ()
{
int x;
  srand (time(NULL));
  for (x=0;x < 10; x++)
  {
    printf ("Numero: %d\r\n", rand() ); 
  }
  return 0;
}
PD: If you guys comment the line of the srand we can see the difference.

No comments: