Message-Id: <199801160123.RAA23681@m3.sprynet.com> Reply-To: From: "Don Arnold" To: "Geoff J. Howard" , Subject: Re: rand() problem Date: Thu, 15 Jan 1998 19:14:00 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Precedence: bulk you'll need to seed the rng with a call to srand() before you use it. ---------- > From: Geoff J. Howard > To: djgpp AT delorie DOT com > Subject: rand() problem > Date: Thursday, January 15, 1998 13:02 PM > > Hello All, > > I am just new to the djgpp world of C computing and I tried out a > simple random number program and kept getting the same "random" number > generated all the time, which is either 0 or no number. Is this a known > problem? I have included the code below. I am thinking that it could be as > a result of my computer not having enough RAM, what is the minimum amount > I should have to run djgpp properly. Thanks all > > Geoff > > #include > #include > > main () > { > int i; > > for (i=1; i<= 20; i++) { > printf("%10d", 1 + (rand() % 6)); > > if (i % 5 == 0) > printf("\n"); > } > > return 0; > }