All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups

Detailed Description

Standard math functions.

Function Documentation

int rand ( )

Generate a pseudo-random integer between 0 and RAND_MAX inclusive.

This function can be seeded by srand().

A simple way to change the range to be an integer between 0 and n-1 inclusive is using % e.g. rand() % n.

Returns
The pseudo-randomly generated number
void srand ( unsigned int  seed)

Seed the pseudo-random number generator.

If you would like a different sequence every time your app starts, you may use time() as a seed e.g. srand(time(NULL)).

This affects subsequent calls to rand() to produce a sequence of numbers for a given seed value. You can use this to either create a different sequence of numbers by always using a different seed or to obtain the same sequence of numbers by reusing the same seed.

Parameters
seedThe source number used to generate a sequence of pseudo-random numbers

Macro Definition Documentation

#define RAND_MAX

The maximum integer value rand() may return.