Defined in header
void srand( unsigned seed );
Seeds the pseudo-random number generator used by rand() with the value
rand() is used before any calls to
rand() behaves as if it was seeded with
rand() is seeded with the same
seed, it must produce the same sequence of values.
srand() is not guaranteed to be thread-safe.
|seed||-||the seed value|
 Return value
Generally speaking, the pseudo-random number generator should only be seeded once, before any calls to
rand(), and the start of the program.
It should not be repeatedly seeded, or reseeded every time you wish to generate a new batch of pseudo-random numbers.
Standard practice is to use the result of a call to time(0) as the seed.
time() returns a time_t value, and
time_t is not guaranteed to be an integral type.
In practice, though, every major implementation defines
time_t to be an integral type, and this is also what POSIX requires.
Random value on [0 2147483647]: 1373858591
- C11 standard (ISO/IEC 9899:2011):
- 22.214.171.124 The srand function (p: 346-347)
- C99 standard (ISO/IEC 9899:1999):
- 126.96.36.199 The srand function (p: 312-313)
- C89/C90 standard (ISO/IEC 9899:1990):
- 188.8.131.52 The srand function
 See also
| generates a pseudo-random number |
| maximum possible value generated by rand() |
C++ documentation for srand