#include <stdlib.h>int rand(void);
The
rand( )
function generates a sequence of pseudorandom
A
#include <setjmp.h>int setjmp(jmp_buf envbuf );
The setjmp( ) macro stores the contents of the system stack in the buffer envbuf for later use by longjmp( ) . It uses the header < setjmp.h >, or < csetjmp > in a C++ program.
The
setjmp( )
macro returns zero upon invocation. However,
longjmp(
)
A
#include <signal.h>void (*signal(int signal , void (* func )(int))) (int);
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. It uses the header < signal.h >, or < csignal > in a C++ program.
The value of func can be the address of a signal handler function or one of the following macros, defined in < signal.h >:
|
Macro |
Meaning |
|---|---|
|
SIG_DFL |
Use default signal handling |
|
SIG_IGN |
Ignore the signal |
If a function address is used, the specified handler will be executed when its signal is received. Check your compiler’s documentation for additional details.
On success, signal( ) returns the address of the previously defined function for the specified signal. On error, SIG_ERR (defined in < signal.h >) is returned.
A
#include <stdlib.h>void srand(unsigned int seed );
The
srand( )
function sets a starting point for the sequence generated by
rand( )
. (The
rand( )
function returns pseudorandom
srand( ) is often 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 starting the sequence.
A
#include <stdlib.h>double strtod(const char * start , char ** end );
The strtod( ) function converts the string representation of a number stored in the string pointed to by start into a double and returns the result.
In C99, start and end are qualified by restrict .
The
strtod( )
function works as
If overflow occurs, either HUGE_VAL or – HUGE_VAL (indicating positive or negative overflow) is returned, and the global variable errno is set to ERANGE , indicating a range error. If underflow occurs, the function returns zero and the global variable errno is set to ERANGE . If start does not point to a number, no conversion takes place and zero is returned.
Related functions are
atof( )
,