Currently At: Programming Reference > C Reference > Other standard C functions > srand()

srand()


Syntax:
#include <stdlib.h>
void srand( unsigned seed );


Description:
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.

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


Related Topics:
rand(), time()


Web Standards & Support:

Link to and support eLook.org Powered by LoadedWeb Web Hosting
Valid XHTML 1.0! Valid CSS! eLook.org FireFox Extensions