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

  • From: "John Tegen" <john@xxxxxxxxxxxxxxx>
  • To: <openbeos@xxxxxxxxxxxxx>
  • Date: Fri, 9 Apr 2004 16:30:24 -0700

Give random generator a seed of time().

-----Original Message-----
From: openbeos-bounce@xxxxxxxxxxxxx
[mailto:openbeos-bounce@xxxxxxxxxxxxx]On Behalf Of Andre Stark
Sent: Friday, April 09, 2004 2:19 PM
To: openbeos@xxxxxxxxxxxxx
Subject: [openbeos] is rand() really random?

Hello there,
this is not really an OBOS problem, but a BeOS one. Everytime i execute 
the following code:

for (int i = 0; i < 100; i++)
                cout << "Random:" << rand() <<endl;

the resulting values are exactly the same? Until now i do'nt know much 
about C++ programming, but normally random numbers are generated by 
including system time in some kind. How does this work on BeOS?

  Andre Stark

Other related posts: