Mail Archives: djgpp/1998/02/03/22:02:27
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 -