Re: Can someone explain the difference between...

  • From:
  • To:
  • Subject: Re: Can someone explain the difference between...
  • Date: Mon, 25 Feb 2013 10:26:32 +0100 (CET)

----- Original Message -----
> rand(); and srand()?
> 
> when and how should I use each?

srand() is to set the seed. This controls the starting point for the sequence 
of numbers that will be generated. This is deterministic. If you want the 
seed to change every time, you can use something like the time for the seed.

rand() will return a uniformly distributed random number.

Note that rand() is not thread-safe as it uses a global variable inside the C 
standard library for the seed.

A+
Paul




Can someone explain the difference between...

redawkin 02/25/2013

Can someone explain the difference between...

soldatov 02/25/2013

Re: Can someone explain the difference between...

paulf 02/25/2013

Project Features

About this Project

CND was started in November 2009, is owned by Leonid Lenyashin, and has 130 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close