X-Sender: dlanor AT mail DOT dds DOT nl Message-Id: In-Reply-To: <7hmakj$t6h$1@cubacola.tninet.se> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sun, 16 May 1999 23:52:20 +0200 To: djgpp AT delorie DOT com From: Dlanor Blytkerchan Subject: Re: ** Random error ** Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk >Can somebody tell how I do to set the variable "int i" to a random number >from 1 to x? Try this macro: #define rnd(x,y) ((random()/RAND_MAX)*(y-x) + x); include stdlib and it should work like this int my_random_number = (int)rnd(1, my_top_number); Greetz! Dlanor NB: sometimes, using rand() is recommended over using random(). Why is not entirly clear, look it up in libc.