srand [C++ Reference]
Keywords: c,other,srand
Date: 2009-09-13T11:48:31-0700

[[srand]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## srand

Syntax:

        #include <cstdlib>
        void srand( unsigned seed );

The function srand() is used to seed the random sequence generated by rand(). For any given seed, rand() will generate a specific “random” sequence over and over again.

         srand( time(NULL) );
         for( i = 0; i < 10; i++ )
           printf( "Random number #%d: %d\n", i, rand() );

Related Topics: rand, (Standard C Date & Time) time

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •