cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/03/22:02:27

From: Myknees AT aol DOT com
Message-ID: <49429c31.34d7b4bf@aol.com>
Date: Tue, 3 Feb 1998 19:22:21 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]

In article <Pine DOT SUN DOT 3 DOT 91 DOT 980203120516 DOT 21682Y-100000 AT is>, Eli Zaretskii
<eliz AT is DOT elta DOT co DOT il> writes:

>The Evil Empire of Creeping Typos strikes back? ;-)


If I was Charlie Brown I would say, "AAAAAAAAAAAARRRRRRRRRRRRGH!!!"

*** src/libc/ansi/stdlib/rand.old	Mon Jul 10 01:39:56 1995
--- src/libc/ansi/stdlib/rand.txh	Tue Feb  3 18:50:08 1998
***************
*** 5,24 ****
  #include <stdlib.h>
  
  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
  
--- 5,48 ----
  #include <stdlib.h>
  
  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
  

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019