www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/12/30/17:18:09

X-Originating-IP: [200.42.4.138]
From: "Norberto Alfredo Bensa" <ceo AT nbensacomputers DOT com>
To: "DJGPP" <djgpp AT delorie DOT com>
References: <92ldqa$300$1 AT news DOT inet DOT tele DOT dk>
Subject: Re: small problem with namegenerator.
Date: Sat, 30 Dec 2000 19:10:57 -0300
Organization: nBens@ Computers
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Message-ID: <OE29NX6Mma0n7J95K7a000029a1@hotmail.com>
X-OriginalArrivalTime: 30 Dec 2000 22:13:15.0618 (UTC) FILETIME=[B4E4DC20:01C072AD]
Reply-To: djgpp AT delorie DOT com

From: "neohashi" <Neohashi AT mail DOT tele DOT dk>
> Hi to all,
>
> I am trying to make a random name generator, but thou they are random, all
> 2000 names ends up the same... what is wrong here??
>
> [snip]
>
>  char *n1,*n2,*n3,finalname[11];
>
>  for(n=0;n<2000;n++)
>  {
>       ran = (random()%10);
>
>       if(ran <= 5)
>          n2 = "ka";
>       else
>          n2 = "cona";
>

bug, should be:

if (ran <= 5)
    n1="ka";
else
    n1 = "cona";


Anyway, you'll only get 8 diffrent names... 2^3 = 8...

Regards,
Norberto





- Raw text -


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