srand function
srand seeds the random number generation function
rand
so it does not produce the same sequence of numbers.
Library: stdlib.h
Prototype: void srand(unsigned int seed);
Syntax: unsigned int seed=10; /* seed value */
srand();
Notes
-
Obviously the seed has to change every time the program is run.
One way to do this is to feed it the O/P from time
example program.
See also:
rand Generate a randon number generator.
time get the calender time (Number of seconds
since 1st Jan 1970.
Martin Leslie