delorie.com/archives/browse.cgi | search |
From: | James McCue <ALOITERER AT prodigy DOT net> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: rand() problem |
Date: | Wed, 14 Jan 1998 11:47:33 -0500 |
Organization: | Talking to the lampost productions |
Lines: | 32 |
Message-ID: | <34BCEC25.41AF@prodigy.net> |
References: | <Pine DOT OSF DOT 3 DOT 96 DOT 980115125749 DOT 12355A-100000 AT duke DOT usask DOT ca> |
Reply-To: | aloiterer AT juno DOT com |
NNTP-Posting-Host: | port101.emea.prodigy.net |
Mime-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Geoff J. Howard wrote: > #include <stdio.h> > #include <stdlib.h> > > main () > { > int i; > > for (i=1; i<= 20; i++) { > printf("%10d", 1 + (rand() % 6)); > > if (i % 5 == 0) > printf("\n"); > } > > return 0; > } You have to "seed" the random number generator Use srand( <- put something in here -> ); before the loop... prior to using DJGPP myself, I would use the value of my timer as the seed... I'd appreciate seeing how that would work in DJGPP Jim the loiterer http://members.xoom.com/JimMcCue/index.htm I love you all!!
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |