Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!helios!stat!john From: john@stat.tamu.edu (John S. Price) Newsgroups: comp.lang.c Subject: Re: randomness Message-ID: <4878@helios.TAMU.EDU> Date: 8 Apr 90 23:21:24 GMT References: <21274@eerie.acsu.Buffalo.EDU> Sender: usenet@helios.TAMU.EDU Reply-To: john@stat.tamu.edu (John S. Price) Organization: Statistics Department, Texas A&M University Lines: 31 In article <21274@eerie.acsu.Buffalo.EDU> sicolo@acsu.Buffalo.EDU (james sicolo) writes: > > What function must one use to get different sequences of random >numbers each time the program is run???? > > By just using random(), I get the same sequence each time. Is there >another function to use ?? > > Jim You need to seed your random number generator. If you are using rand(), use srand() to seed the rrandom number generator. Send srand() some value that you will know change each time you run the program, like time(NULL). So, ... srand(time(NULL)); ... x = rand(); ... That's how I do it, anyway... -------------------------------------------------------------------------- John Price | It infuriates me to be wrong john@stat.tamu.edu | when I know I'm right.... --------------------------------------------------------------------------