| ![[Previous]](../image-lib/prev.gif) | ![[Contents]](../image-lib/contents.gif) | ![[Next]](../image-lib/next.gif) | 
Reset the state of a pseudo-random number generator
#include <stdlib.h> char *setstate( const char *state );
libc
Once the state of the pseudo-random number generator has been initialized, setstate() allows switching between state arrays. The array defined by the state argument is used for further random-number generation until initstate() is called or setstate() is called again. The setstate() function returns a pointer to the previous state array.
This function is used in conjunction with the following:
After initialization, you can restart a state array at a different point in one of two ways:
A pointer to the previous state array, or NULL if an error occurred.
See initstate().
| Safety: | |
|---|---|
| Cancellation point | No | 
| Interrupt handler | No | 
| Signal handler | No | 
| Thread | No | 
drand48(), initstate(), rand(), random(), srand(), srandom()
| ![[Previous]](../image-lib/prev.gif) | ![[Contents]](../image-lib/contents.gif) | ![[Next]](../image-lib/next.gif) |