For every different seed value used in a call to srand, the pseudo-random number generator can be expected to generate a different succession of results in the subsequent calls to rand.
Two different initializations with the same seed, instructs the pseudo-random generator to generate the same succession of results for the subsequent calls to rand in both cases.
If seed is set to 1, the generator is reinitialized to its initial value and produces the same values as before any call to rand or srand.
In order to generate random-like numbers, srand is usually initialized to some distinctive value, like those related with the execution time. For example, the value returned by the function time (declared in header <ctime>) is different each second, which is distinctive enough for most randoming needs.
- An integer value to be used as seed by the pseudo-random number generator algorithm.
First number: 41 Random number: 13 Again the first number: 41
|rand||Generate random number (function)|