compute a sequence of pseudo-random integers
#include <stdlib.h> int rand( void );
The rand() function computes a sequence of pseudo-random integers in the range 0 to RAND_MAX (32767). The sequence can be started at different values by calling the srand() function.
A pseudo-random integer.
#include <stdio.h>
#include <stdlib.h>
void main()
{
int i;
for( i=1; i < 10; ++i ) {
printf( "%d\n", rand() );
}
}
ANSI
| Safety: | |
|---|---|
| Interrupt handler | Yes |
| Signal handler | Yes |
| Thread | Yes |