The old way to get random numbers is with srand(time (NULL)) function for initialization, rand() to get the random number, and rand() % maxValue to get a random number between 0 and maxValue. But after I watched Stephan T. Lavavej’s statements on this video, the usage of simple rand() plus modulus paradigm was considered harmful and terrible. Why?
According to C++ documentation of rand(), you’ll see this..
Returns a pseudo-random integral value between 0 and RAND_MAX (0 and RAND_MAX included)
Now, see the documentation of RAND_MAX and you will see this..
This value is implementation dependent. …