This section describes the random number functions that are part of the ANSI C standard.
To use these facilities, you should include the header file `stdlib.h' in your program.
rand
function. In the GNU library, it is 037777777
, which is the largest signed integer representable in 32 bits. In other libraries, it may be as low as 32767
.
rand
function returns the next pseudo-random number in the series. The value is in the range from 0
to RAND_MAX
.
rand
before a seed has been established with srand
, it uses the value 1
as a default seed.
To produce truly random numbers (not just pseudo-random), do srand (time (0))
.