Mail Archives: djgpp/1998/02/02/22:52:01
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 <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
--- 1,48 ----
@node rand, random number
! n AT subheading Syntax
@example
#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 -