Re: How to make a random number
On Wed, 26 Apr 2000, John Galt wrote:
>
> #include <time.h>
> #include <stdlib.h>
>
> int main ()
> {
> srand (time (0));
> /* rest of program would be here */
> }
>
> This is the way they teach it in Deitel & Deitel...
no idea who D&D are but the best way IMO
is to feed srand off /dev/urandom
>
>
>
> On Thu, 27 Apr 2000, Alex Weiss wrote:
>
> > Hi folks,
> > how do you generate random numbers in C? I know, there are functions in
> > stdlib.h (rand, srand). But at every execution they generate the same
> > number and that's bad for the purpose of my program.
> > Do I have to use time and date functions?
> >
> > Thanks in advance,
> >
> > --
> > Alex Weiss
> > alexweiss@freesurf.ch
> > www.gnu.org
> > Software is like sex: it's better when it's free (Linus T.)
> >
> >
> > --
> > To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
> > with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> >
>
> Galt's sci-fi paradox: Stormtroopers versus Redshirts to the death.
>
> Who is John Galt? galt@inconnu.isu.edu, that's who!
>
>
>
> --
> To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>
OK
Reply to: