Excerpt from: Baidu Encyclopedia
The prototypes of these two functions in stdlib.h are:
int rand (); void srand (unsigned int);
? in the standard C library, the function RAND () can generate a random number between 0~rand_max, where Rand_max is an integer defined in Stdlib.h, which is related to the system. In order for the program to generate random values for a new sequence each time it executes, we usually provide a new random seed for the random number generator. the function srand () can spread the seed for the random number generator. as long as the seed is different, the rand () function produces a different sequence of random numbers. Srand () is called the initializer of the random number generator.
Usage:
Srand (Time (NULL)); randnum = rand ();
So Randnum is a real random number.
rand () generates pseudo-random numbers, srand functions provide seeds , and seeds produce different sequences of random numbers, so the Srand function is usually called first time () ( from Time.h Returns the time of the system (from Midnight 1970.1.1), in seconds, the same probability that the seed will produce the same number of random numbers is very small.
How to generate random numbers using Srand () and random number functions rand () in C language