Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!tank!shamash!com50!jhereg!mark From: mark@jhereg.Jhereg.MN.ORG (Mark H. Colburn) Newsgroups: comp.lang.c Subject: Re: How do I get random #s? Message-ID: <510@jhereg.Jhereg.MN.ORG> Date: 3 Feb 89 00:41:10 GMT References: <19415@dhw68k.cts.com> Reply-To: mark@jhereg.MN.ORG (Mark H. Colburn) Organization: Minnetech Consulting, Inc., St. Paul MN Lines: 33 In article <19415@dhw68k.cts.com> tsource@dhw68k.cts.com (Aryeh Friedman) writes: > I am new to C and I want to know how to get random numbers returned. There are several different variations on how to get random numbers in C. On most System V based systems and when using ANSI C you would use the function srand() to provide a random number seed (if you want one) and the rand() function to get a randon number back. unsigned int seed; int num; seed = ???; srand(seed); num = rand(); On most BSD derived systems you would use srandom() to provide the seen and the random() function to get the random number back. int seed; long num; seed = ???; srandom(seed); num = random(); -- Mark H. Colburn "Look into a child's eye; Minnetech Consulting, Inc. there's no hate and there's no lie; mark@jhereg.mn.org there's no black and there's no white."