From: Endlisnis 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 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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 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 > > 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