srand. McGraw-Hill The Complete Reference Fourth Edition
Advertentie
Advertentie
C h a p t e r 3 0 : U t i l i t y F u n c t i o n s
771
The signal( ) function registers the function pointed to by func as a handler for the signal specified by signal. That is, the function pointed to by func will be called when
signal is received by your program.
The value of func may be the address of a signal handler function or one of the following macros, defined in <csignal>:
Macro
SIG_DFL
SIG_IGN
Meaning
Use default signal handling
Ignore the signal
If a function address is used, the specified handler will be executed when its signal is received.
On success, signal( ) returns the address of the previously defined function for the specified signal. On error, SIG_ERR (defined in <csignal>) is returned.
A related function is raise( ).
srand
#include <cstdlib> void srand(unsigned seed);
The srand( ) function is used to set a starting point for the sequence generated by
rand( )
. (The rand( ) function returns pseudorandom numbers.)
srand( )
is generally used to allow multiple program runs to use different sequences of pseudorandom numbers by specifying different starting points. Conversely, you can also use srand( ) to generate the same pseudorandom sequence over and over again by calling it with the same seed before obtaining each sequence.
A related function is rand( ).
strtod
#include <cstdlib> double strtod(const char * start, char **end);
Downloaden
Advertentie