Re: [NEWBIE][CODE] spirit world snippet

From: Thomas Arp (t_arp@stofanet.dk)
Date: 08/05/02


From: "Peter d" <death_comes_to_all@HOTMAIL.COM>
<snip>
>         if (argument != "lorkhan"){
>            send_to_char(ch, "Bribe who?\r\n");
>         } else if (argument == "lorkhan"){
<snip>
> can anyone see what the problem might be?
>
You're comparing strings the wrong way[1].
To compare strings, use the str_cmp() function:

skip_spaces(&argument);
if (str_cmp(argument, "lorkhan")) {
  send_to_char(ch, "Bribe who?\r\n");
} else {...

or you might consider using abbreviations:

skip_spaces(&argument);
if (!is_abbrev(argument, "lorkhan")) {
  send_to_char(ch, "Bribe who?\r\n");
} else {...

> and another question, i have been away for a month, and i was hoping to
see
> dg for bpl21 on the ftp.. when will it be

http://www.circlemud.org/pub/CircleMUD/contrib/scripting/

Welcor

[1] This is very much a newbie error. The statement
    'if (argument == "lorkhan")' means literally:
    'if the memory position pointed to by the pointer ´argument´ is
    the same as the memory position of the first character in the
    constant string "lorkhan"', which isn't what you meant to check.
    Since C is a quite lowlevel language, this functionality is needed
    sometimes, when dealing with pointers.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT