Re: Problem with Arguments

From: Sammy (samedi@DHC.NET)
Date: 09/19/97


On Fri, 19 Sep 1997, Cris Jacobin wrote:

>      if (itm_name=="brown") {
>
>     Why the individual conditional statements never evaluate to true, I
> can't figure out for the life of me.  It invariably falls down and executes
> the else/default chunk, displaying, 'there is no such item.'

A good clue would be to get a C book and brush up on the peculiarities of
C syntax.

A better clue would be that neither itm_name nor "brown" are what you
would consider strings.  Sure, they look like strings, but a C compiler
treats both as character pointers (char *).  itm_name is a pointer to the
array of characters copied from the player's command argument.  "brown" is
treated as a pointer to the static string "brown".  Even though the data
may be equal, the pointers aren't, so it evaluates false.

Another really good clue would be to take a peek at one of the many
existing spec_procs in circle to see how you can fix it.

Sam


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST