#: 5538 S3/Languages
25-Jul-90 06:11:20
Sb: #5502-#Clib docs
Fm: Mark Griffith 76070,41
To: Bob van der Poel 76510,2203 (X)
Bob,
Huh, rand() is right. I talked to Carl when there was a hubbub here about how
to use it and he gave me the scope. Rand() has no scale and srand() is used to
seed it. The example I gave in the docs works. Here is another:
#include
main()
{
long time();
srand((unsigned) time(0)); /* seed the generator */
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
srand((unsigned) time(0)); /* reseed the generator */
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
printf("%d\n", rand());
}
Mark
There is 1 Reply.
|