That did it.  Needed to initialize.  There were no warnings tho.  I get
rid of those when I compile.
But thanks to everyone who helped.

-----Original Message-----
From: Chad Simmons [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 10, 2004 3:03 PM
To: Mervine, Keith
Cc: [email protected]
Subject: Re: Problem with an array



--- "Mervine, Keith" <[EMAIL PROTECTED]> wrote:
You know those warnings you get when you compile? Those are there for a
reason.
When you're compiling this function it's probably giving you some
warnings
about the variable lottery being used before it's initialized. Don't
ignore
this! Lottery is a pointer, it has to point to some peice of valid
memory. When
it hasn't been initialized it points to some random point in memory, and
by
iterating over that and/or modifying the data being pointed to you will
at best
munge you games internal structure causing numerous glitches until the
game is
restarted. At worst it will cause a crash. Always initialize your data
before
you use it. And pay attention to warnings your compilier gives you.

> void do_generate(CHAR_DATA *ch)
> {
>   int num1, num2, num3;
>   int pnum1, pnum2, pnum3;
>   int i;
>   LOTTERY_DATA *lottery;
> 
>   num1 = dice(1,1);
>   num2 = dice(1,1);  //Testing all will be 0,9
>   num3 = dice(1,1);
> 
>   for (i=0;i<maxLottery;i++)
>   {
>    pnum1 = lottery[i].slot1;
>    pnum2 = lottery[i].slot2;
>    pnum3 = lottery[i].slot3;
> 
>    if (pnum1 == num1 && pnum2 == num2 && pnum3 == num3)
>    {
>     info (ch,0,"We have a winner!\n\r");
>    }
>   }
> }
> 
> Using GDB I look at pnum1 pnum2 and pnum3 and they turn into something
> like 824193073
> 
> 
> Any help would be ...well...helpful!


=====
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/L/C/O d-(+) s++: a-- C+++$>++++ UBLS++++$ 
P+++(--)$ L+++>++++ E--- W+>++$ N !o K? w(--) !O 
M- !V PS+ PE(++) Y+ PGP->+ t+ 5 X+() R(+) tv+@ 
b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++
------END GEEK CODE BLOCK------


        
                
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 

Reply via email to