[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
srand() Set Random Starting Point
#include <stdlib.h> Required for declarations only
void srand(seed);
unsigned seed; Seed for random-number generation
srand() provides the starting point for the series of pseudorandom
integers generated by the function rand(). The generator is
reinitialized by calling srand() with 1 as the 'seed' argument; any
other value of 'seed' sets the generator to a random starting point.
Returns: There is no return value.
-------------------------------- Example ---------------------------------
The following statements generate 10 random numbers.
#include <stdlib.h>
#include <stdio.h>
int i, seed = 20;
int num;
main()
{
srand(seed);
printf(" RANDOM NUMBERS \n");
for (i = 1; i <= 10; i++)
printf("index: %d, random number: %d \n",i,rand());
}
See Also:
rand()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson