Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/setstate.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/setstate.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/setstate.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/setstate.html on line 8
Reset the state of a pseudo-random number generator
#include <stdlib.h>
char *setstate( const char *state );
- state
- A pointer to the state array that you want to use.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
|
This function is in libc.a, but not in libc.so
(in order to save space). |
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:
- initstate()
- Initialize the state of the pseudo-random number generator.
- random()
- Generate a pseudo-random number using a default state.
- srandom()
- Set the seed used by the pseudo-random number generator.
After initialization, you can restart a state array at a different point in
one of two ways:
- Call initstate() with the desired
seed, state array, and size of the array.
- Call setstate() with the desired state, then
call srandom() with the desired seed. The
advantage of using both of these functions is that the
size of the state array doesn't have to be saved once it's initialized.
A pointer to the previous state array, or NULL if an error
occurred.
See initstate().
POSIX 1003.1 XSI
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
No |
Thread |
No |
drand48(),
initstate(),
rand(),
random(),
srand(),
srandom()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/setstate.html on line 171
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/setstate.html on line 171