From: Myknees AT aol DOT com Message-ID: Date: Mon, 2 Feb 1998 22:33:15 EST To: eliz AT is DOT elta DOT co DOT il Cc: dj AT delorie DOT com, djgpp AT delorie DOT com Mime-Version: 1.0 Subject: Re: Documentation [was Re: Random implementation] Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit Precedence: bulk The latest changes: leaving out reference to source; fixed typo; ran diff from djgpp.env's directory; called the new version rand.txh; removed extra texi markup from example. There's no hypertext link to the docs (that aren't there) for srand(), though. *** src/libc/ansi/stdlib/rand.old Mon Jul 10 01:39:56 1995 --- src/libc/ansi/stdlib/rand.txh Mon Feb 2 22:21:20 1998 *************** *** 1,24 **** @node rand, random number ! @subheading Syntax @example #include int rand(void); @end example @subheading Description Returns a pseudo-random number from zero to @code{RAND_MAX}. @subheading Return Value ! The number. @subheading Example @example /* random pause */ for (i=rand(); i; i--); @end example --- 1,48 ---- @node rand, random number ! n AT subheading Syntax @example #include int rand(void); + void srand(unsigned _seed); @end example @subheading Description Returns a pseudo-random number from zero to @code{RAND_MAX}. + This function has its own default seed but may also be seeded with the + function @code{srand}. It is + only necessary to use @code{srand} in the following cases: + + @itemize @bullet + + @item + + If the pseudo-random sequence must be different each time you run the + program + + @item + + If the sequence must continue from the same place it ended on some + previous run + + @end itemize + @subheading Return Value ! The pseudo-random number. @subheading Example @example /* random pause */ for (i=rand(); i; i--); + @end example + + @example + /* seed rand with current time */ + srand(time(0)); @end example