Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>srand() set random starting point</b> http://www.X-Hacker.org [<<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().  When srand() is called
    with 1 as the 'seed' argument, the random-number generator is
    reinitialized; any other value of 'seed' sets the generator to a
    random starting point.

       Returns:     Nothing

   -------------------------------- 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()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson