Path: utzoo!attcan!uunet!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!amigo From: amigo@milton.u.washington.edu (Michael Robertson) Newsgroups: comp.lang.c Subject: rand() and examples Keywords: rand() c programming random Message-ID: <9655@milton.u.washington.edu> Date: 21 Oct 90 21:39:45 GMT Organization: University of Washington, Seattle Lines: 28 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 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