www.delorie.com/archives/browse.cgi | search |
From: | Endlisnis <s257m AT unb DOT ca> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: SV: ** Random error ** |
Date: | Mon, 17 May 1999 19:44:24 -0400 |
Organization: | BrunNet |
Lines: | 32 |
Message-ID: | <3740A9D8.B3D92BBE@unb.ca> |
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> |
NNTP-Posting-Host: | ftnts4c38.brunnet.net |
Mime-Version: | 1.0 |
X-Mailer: | Mozilla 4.51 [en] (Win95; U) |
X-Accept-Language: | en |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
"Börje Granberg" wrote: > > 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; > I tested it but there comes the same numbers evertime! > You need to give a seed to the random number generator (use srand(time(0))). -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT HotMail DOT com ICQ: 32959047
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |