I believe you are having a problem, because you aren't initializing what
struct it is.
bool has_been_guessed( struct wordtwist_data *pWrd, char *word ) {
char log_buf[MAX_INPUT_LENGTH];
int i;
for( i = 0 ; i < pWrd->guess_count ; i++ ) //this crashes on second+
guess
if(!str_cmp(word, pWrd->guesses[i]) )
return TRUE;
return FALSE;
}
The reason it is crashing there is because you declared pWrd, but you didn't
set it to any value, so it's trying to find pWrd->guess_count but pWrd is
actually NULL.
How you are going to go about doing it? I have a couple ideas but don't know
exactly what you are doing or what result you are trying to get so my
suggestions wouldn't be very helpful.
Although I would like to point out, that's like the below code.
Void check_my_char()
{
CHAR_DATA *ch;
If (Ch->guesses == 1) <-- it'd crash here cause ch is declared, but not
initialized.
}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tristan M
Sent: Monday, August 23, 2004 5:50 PM
To: [email protected]
Subject: Re: a problem with checking if a word has been entered already
yeah, my problem was i wasnt initializing it, i made this(copied it from
help_data in recycle.c) and put it in db.c and now pWrd-> works fine
WORDTWIST * word_free;
WORDTWIST * new_word ( void )
{
WORDTWIST * word;
if ( word_free )
{
word = word_free;
word_free = word_free->next;
}
else
word = alloc_perm( sizeof( *word ) );
word->newround = TRUE;
return word;
}
although maybe im missing something because it still doesnt want to work
properly at this part:
bool has_been_guessed( struct wordtwist_data *pWrd, char *word )
{
char log_buf[MAX_INPUT_LENGTH];
int i;
for( i = 0 ; i < pWrd->guess_count ; i++ ) //this crashes on second+
guess
if(!str_cmp(word, pWrd->guesses[i]) )
return TRUE;
return FALSE;
}
i think the problem here is that guesses[i] isnt increasing, and instead
just crashes.
right now im running this on a windows machine, so now gdb(i dont know how
to use it) but im uploading it to my shell right and will put it there, so
once thats going can anyone briefly explain how i can use gdb to single out
the problem here?
>From: Davion Kalhen <[EMAIL PROTECTED]>
>Reply-To: Davion Kalhen <[EMAIL PROTECTED]>
>To: [email protected]
>Subject: Re: a problem with checking if a word has been entered already
>Date: Mon, 23 Aug 2004 12:10:56 -0700
>
>Sounds like your entire variable is uninitalized. It'd be nice if you
>showed us a gdb backtrace, so we know exactly whats wrong. Even show
>the value of pWrd->newround. But generally, when you create a new
>pWrd, via new_word() or something like that, functions are in
>recycle.c. They should atleast be initalized to zero. I'm not sure if
>newround is a pointer, or not, so I can't tell ya whats wrong. But
>honastly it sounds like pWrd is uninitalized. Make sure your setting
>it up properly. Maybe show us a code snippet of where it crashes. As
>well show us what newround is, and the gdb backtrace! If you don't
>know how to use gdb... your screwed! :P Just ask we will tell.
>
>Davion
>
>--
>ROM mailing list
>[email protected]
>http://www.rom.org/cgi-bin/mailman/listinfo/rom
_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented MicrosoftR
SmartScreen Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=htt
p://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSNR Premium right now and get the
first two months FREE*.
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom