From: Jason Alexander Newsgroups: comp.os.msdos.djgpp Subject: Automatically seeding random numbers Date: Tue, 03 Feb 1998 22:10:42 -0800 Organization: University of California, Irvine Lines: 22 Message-ID: <34D80662.CD7C1FC@ea.oac.uci.edu> NNTP-Posting-Host: pv1821.pv.reshsg.uci.edu 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 Please excuse my asking what is probably a simple question, but since I'm teaching myself how to program in C using djgpp, I don't yet know how to figure out this problem. Basically, I'd like a program to (automatically) seed srand() with a different value each time the program is run. (Currently I require the user to type in a seed, which is a nuisance.) Initially, I thought something as simple as srand(clock()) would work, but then I found out that clock() only returns the number of clock ticks since the *last* call of clock(), so clock() always returns the value 0 when called for the first time. Is there, say, a way to get the number of milliseconds after the last minute or something like that? More generally, what is the preferred way of automatically generating such a seed? Thanks, Jason