Generates pseudo-random numbers.
Thread-Safe C Library (libc_r.a)
Berkeley Compatibility Library (libbsd.a)
#include <stdlib.h>
int rand_r (Seed)
unsigned int * Seed;
The rand_r subroutine generates and returns a pseudo-random number using a multiplicative congruential algorithm. The random-number generator has a period of 2**32, and it returns successive pseudo-random numbers.
Programs using this subroutine must link to the libpthreads.a library.
Item | Description |
---|---|
Seed | Specifies an initial seed value. |
Item | Description |
---|---|
0 | Indicates that the subroutines was successful. |
-1 | Indicates that the subroutines was not successful. |
If the following condition occurs, the rand_r subroutine sets the errno global variable to the corresponding value.
Item | Description |
---|---|
EINVAL | The Seed parameter specifies a null value. |
Item | Description |
---|---|
/usr/include/sys/types.h | Defines system macros, data types, and subroutines. |