Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content


Sets the starting seed value for the pseudorandom number generator.

void srand(
   unsigned int seed 


Seed for pseudorandom number generation

The srand function sets the starting point for generating a series of pseudorandom integers in the current thread. To reinitialize the generator to create the same sequence of results, call the srand function and use the same seed argument again. Any other value for seed sets the generator to a different starting point in the pseudorandom sequence. rand retrieves the pseudorandom numbers that are generated. Calling rand before any call to srand generates the same sequence as calling srand with seed passed as 1.


Required header



For additional compatibility information, see Compatibility in the Introduction.

See the example for rand.

© 2015 Microsoft