Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <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().  Using 1 as the 'seed'
    argument reinitializes the generator; any other value of 'seed' sets
    the generator to a random starting point.

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

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