[comp.lang.c] rand

amigo@milton.u.washington.edu (Michael Robertson) (10/22/90)

     I need some definite description how to use the rand() function in
     C. Or, if someone can describe random() then that may help as well.
     I'm creating a game that needs a random number between 1 and 13,
     I want only 1 to 13, not 13.000001, etc. A "demo" I have locally
     was:
     
          include <time.h>
          main()
          {
               unsigned seed=time();   /* grab seed from time() */
               srand(seed);            /* set seed */
               int test_it;            
               test_it == rand()%14;   /* rand() generates numbers, 
                                          % func. limits it..? */
               printf("\nRand=%d", &test_it);
          }
   


          There's of course some stuff wrong with the above I believe.
     If someone can e-mail me correct use of rand() and/or random(),
     it'd be much appreciated..
     
                                                       thanks,
                                                mike robertson
                                                amigo@milton.u.washington.edu