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());
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster