TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: Bob van der Poel 76510,2203 (X)
from: Mark Griffith 76070,41
date: 1990-07-25 06:11:20
subject: #5502-#Clib docs

#: 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.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.