www.delorie.com/archives/browse.cgi | search |
Sender: | root AT delorie DOT com |
Message-ID: | <37406F90.E3AD3CE2@pmail.net> |
Date: | Mon, 17 May 1999 19:35:45 +0000 |
From: | Fred Backman <fredrick DOT backman AT pmail DOT net> |
Organization: | http://www.femmefetish.com |
X-Mailer: | Mozilla 4.5 [en] (X11; I; Linux 2.0.36 i686) |
X-Accept-Language: | en |
MIME-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
Subject: | Re: SV: ** Random error ** |
References: | <7hmakj$t6h$1 AT cubacola DOT tninet DOT se> <373EC6D5 DOT BD3882E0 AT enter DOT net> <7hpfnb$p1d$1 AT zingo DOT tninet DOT se> |
Reply-To: | djgpp AT delorie DOT com |
You will have to "seed" it first by calling srand(N), where N is an integer. Better results if you let N vary, e.g. let N be the equal to seconds in current time or something similar. "Börje Granberg" wrote: > I tested it but there comes the same numbers evertime! > > Sean <sproctor AT enter DOT net> skrev i > diskussionsgruppsmeddelandet:373EC6D5 DOT BD3882E0 AT enter DOT net... > > "Börje Granberg" wrote: > > > > > > Can somebody tell how I do to set the variable "int i" to a random > number > > > from 1 to x? > > > > #include <stdlib.h> > > > > ... > > > > int i = rand() % x + 1;
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |