www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/25/02:59:29

Date: Wed, 25 Apr 2001 10:01:14 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: jfmcginnis95 AT surfbest DOT net
cc: djgpp AT delorie DOT com
Subject: Re: Help w/ Random # Generator gone crazy.
In-Reply-To: <9c5rea$ek7$1@news.chatlink.com>
Message-ID: <Pine.SUN.3.91.1010425095903.22758T-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 25 Apr 2001 jfmcginnis95 AT surfbest DOT net wrote:

> void getScores (int b[], int num)
> 
> {
> 
> cout << endl;
> 
> srand(time(NULL));
> 
> for (int i=0; i < num; i++)
> 
>     b[i] =rand()%100;
> 
> }
> 
> If  I enter 1 through 4 as the number variable for the array it seems to do
> fine.  When I get a larger number of elements in the array though it will
> give me all zeros or huge numbers, positive and negative, that have not
> appeared to have gone through the %100 part of the function.  Anyone have
> any ideas?

An idea: post a short complete program that can be compiled and run.  
Your code snippet has too many unknowns to see what might go wrong.  (For 
exampe, how is b[] declared in the calling routine? how do you print the 
resulting array? and so on, and so forth...)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019