Trying to generate random random numbers!

Miles ONeal meo at Dixie.Com
Mon Mar 18 15:06:43 AEST 1991


Michael A. Sapienza writes:

!I could use some help in generating random numbers.  The problem I am having
!is that I get the same set of numbers each time that I run the program.  I
!have tried using srandom (seed) and entering the seed from the keyboard,
!but this also returns the same random number.  Any help would be greatly
!appreciated!

On what? Using what?

Sounds like your srand() (srandom?) is broken. But the easy way
(if srand() works) is to say

srand ((int) time (0));

(assuming you are on a UNIX system).

You might also check out the drand48() man page.

-Miles

Miles O'Neal
meo at dixie.com              {uunet | emory}!rsiatl!meo



More information about the Comp.unix.programmer mailing list