srandom()

Initialize the random number generator with a seed value.

Syntax

srandom(seed)

Parameter

ParameterDefinition

seed

numeric value used as a starting point for pseudorandom number generation by the random() function

Description

The srandom() function sets the random number seed for the random() function. The seed is passed directly to the Unix C srandom() function. 

The PSL srandom() function always returns the NULL string.

Example

The following is an example of the srandom() function:

srandom(time());
i = 0;
while (i++ <= 5) {
printf("random number %1d is: %3d\n",i,random(100));
}


Was this page helpful? Yes No Submitting... Thank you

Comments