[openbeos] Re: is rand() really random?

  • From: "Jared Eldredge" <jared@xxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Fri,09 Apr 2004 17:48:07 Local time zone must be set--see zic manual page

> [...]
>  Everytime i execute 
> the following code:
> 
> for (int i = 0; i < 100; i++)
>               cout << "Random:" << rand() <<endl;
> 
> the resulting values are exactly the same? 
> [...]
> Greetings
>   Andre Stark

Andre:
look here:
http://www.cplusplus.com/ref/cstdlib/rand.html

srand() is the seed function, pass it the system time to seed the 
random number generator.
i'm pretty sure BeOS implements the standard c library has it was 
supposed to be (*the standard way) and therefore the reference above 
should describe it very well for you.
-jared


--
Automated (hopefully never vulgar) fortune:

Coincidence, n.: 
        You weren't paying attention to the other half of what was
going on.

Other related posts: