[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

srand

Syntax

 
#include <stdlib.h>

void srand(unsigned seed);

Description

Initializes the random number generator for rand(). If you pass the same seed, rand() will return the same sequence of numbers. You can seed from time (see section time) or rawclock (see section rawclock).

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001

Example

 
/* random pause */
srand(time(0));
for (i=rand(); i; i--);