delorie.com/archives/browse.cgi | search |
Newsgroups: | comp.os.msdos.djgpp |
From: | Chris Mangum and Savanna Judd <sneeches AT cruzio DOT com> |
Subject: | Re: Random numbers |
Sender: | news AT cruzio DOT com (System Administrator) |
Organization: | Cruzio Community Networking System, Santa Cruz, CA |
Message-ID: | <3393489B.50A3@cruzio.com> |
References: | <01bc6ce9$72076bc0$363e63c3 AT 8652hvt73761> <338F40EE DOT 5244E66 AT alcyone DOT com> <339110F2 DOT 7537 AT nxus DOT com> |
Mime-Version: | 1.0 |
Date: | Mon, 2 Jun 1997 22:26:35 GMT |
Lines: | 20 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
cjwhite wrote: > > I have been playing around with random numbers for a few days using > random() % (whatever) but the numbers to not appear to be random. It > seems to only randomize when i recompile. I can manually enter a new > seed, but i am using this for a game so i need to have the computer > generate truly random numbers by itself. > > Chris Try using this: srand(time(NULL)); That should use the current time to seed the random generator for you, so you'll get a different series of numbers out of rand() each time you run the program. -Chris Mangum -sneeches AT cruzio DOT com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |