Message-Id: <199811041536.PAA11858@relay.clara.net> From: "Arthur" To: Subject: RE: Random Number Date: Wed, 4 Nov 1998 15:31:21 -0000 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp AT delorie DOT com > srandom(int seed) /* what is the meaning of this 'seed' ?*/ > for( ... ) > { > i=random(); > printf("%u \n",i); > ... > > }; > > Then things: > - Every time I launch the executable, the sequence of so called random > numbers printed on screen is always the same ( so where is the randomized > stuff ?) Computers can't do random numbers. They have to have a special equation which gives the impression of randomness. The randomness comes from the modification of a "seed" value which you have to set to a different value each time you load the program or random will follow the same equation and return the same values each time you run. The most common way to seed the random number generator is to seed it with the current system time, as that will be different each time the program is run. > - How can I manage to have 'i' between 0 and MaxRandomNumber ? i = random() % (MaxRandomNumber + 1); James Arthur jaa AT arfa DOT clara DOT net ICQ#15054819