From: Jason Cain Newsgroups: comp.os.msdos.djgpp Subject: Generating random numbers... Date: Tue, 26 May 1998 17:32:38 -0500 Organization: I hate spam! Lines: 35 Message-ID: <356B4306.936FAA09@SPAM.ti.com.SUCKS> NNTP-Posting-Host: huy.de.sc.ti.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hello, I'm trying to generate a sequence of random numbers, so I wrote a simple program to generate 20 random numbers as a test. I'm using the srandom() function with a seed value generated by rawclock(). I thought this might be a good way to generate a different seed every time. However, rawclock() seems to be returning zero every time, which causes me to get the same sequence of random numbers every time. Can anyone offer any suggestions on what I'm doing wrong or alternate methods? I'm using Windows NT4--perhaps that has something to do with it? Short code follows. Thanks, Jason Cain NOTE: To reply by email, remove the SPAM. and .SUCKS -- #include #include int main() { int c, seed; seed = rawclock(); srandom(seed); printf ("Seed value: %d\n", seed); for(c=0; c < 20; c++) printf("Random number: %d\n", random()); return 0; }