srandom()
Initialize the random number generator with a seed value.
Syntax
srandom(seed)
Parameter
Parameter | Definition |
---|---|
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));
}
i = 0;
while (i++ <= 5) {
printf("random number %1d is: %3d\n",i,random(100));
}
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*